I can't figure out how I should use i18n-node module inside my application.
Within views, for static texts, it's easy, it works perfectly but...
Here is my problem :
Sometimes I have to set some error messages or something else, e.g :
req.flash('message', __('Unknown user %s', login));
Then I'll have to send this message to my views, e.g :
res.render('myview', {message: req.flash('message')});
But first, my message "Unknown user %s" will only be set in the default language json file, and then even if I put "Unknown user %s": "Something in the client language" in the client language json file, it will still display "Unknown user myUserLogin".
Does someone have a good working example to share ?
Edit: And because, there is a variable in the translated string, I can't just do that :
res.render('myview', {message: __(req.flash('message'))});
because it will set "Unknown user myUserLogin" in the client language json file, instead of "Unknown user %s"...
I know this question is kind of old, but I ran into the same issue and found a solution.
Since your using the flash method from the req object, you should also use the __ method available in the same object:
req.flash('message', req.__('Unknown user %s', login));
This way it's gonna be translated using the current locale of the request.
Related
Sometimes when I have wrong configuration etc connect/authorize redirects to my error page (which is empty for now) with an errorId. The question is how to read this errorId using oidc-js?
ErrorId looks like CfDJ8ObXvIAxPKdJmO-cyJSfxpRIoVoFa0SgJlnMuaCjX8vgxZ44J4sFm2S4GG6AScjL4XKZGVLv7kEiVXsQIdC7Z4S5Hz1Eyo-5Fp8DDVcU7yecNaJPl4nG8BbY3FpjSxVcLUzP2Ef4FWVCtTDD7M9p97x0W7Ll7Q-_MYdVJ6i1fzQC2Rk_j0hkkbTb-HNIYY9mE8x9jcw0PF0TPSEStlL143HaEocsp5rNsKfaW4lEbamg-lFW0qHfCplC_LvIe2r2XZX1qeRuS6BobcL5e_Avk0R7wNuWViwN2rgzaahyvEJOcEY2fMaLBGjftDCm1uQhST1FIJ60kTX5sFF6NR5CNvp-Y6X8_aEEZ9IEj1ahaVSS
'errorId' in this context is protected using serverside data protection keys so you can't do anything with it client side. However identityserver4 does provide a service for handling these errors in the form of IIdentityServerInteractionService.GetErrorContextAsync(errorId) so you can implement that in your error controller and return any information you like in the resulting view/output.
Have anyone encountered this Error message, when trying to connect to ArangoDB from a React application [See first attached photo]? It seemed like, it could be an issue related to authentication... but I've tried using "_system" and my own databases, with booth "root" as username and with "root" as password as well as setting the password to "null". I've tried to create new users and tried to connect to the database... Nothing works... (what am I doing wrong? - I've gone through the documentation a billion times at this point). I will attach a photo of my code as well.
Image of error,
Image of my code
Here is a link to the list of error codes. Unfortunately, "error 0" is extremely unhelpful. However, I see two potential issues.
First is with your use of HTTPS - normally, you use would use HTTP to connect to port 8529. One caveat would be TLS (like --server.endpoint "http+tcp://127.0.0.1:8529" with arangosh), but that's not the same as HTTPS.
Second, your AQL query seems to be attempting to return an entire collection, which is not how AQL works. Try returning a static like RETURN 'yes' or use the format:
FOR doc IN collection
RETURN doc
Hi i want to store wordings used in my application where i could easily get them and use/reuse them.
Some example of wordings like loading messages or validation messages, or any information messages.
I have tried using .resx files to store some of these but one thing i hate about is i need to get that wording on the server which i get lazy after doing it so many times.
I also tried storing them in a javascript array but i realized that any user might be able to see all those wordings since it is stored on the client side. But i dont have anything to hide there. It is just i feel that it is not the right thing to do maybe?
Anybody has any good suggestions?
If you want to store just some messages javascript is absolutely fine.
I may suggest you the following approach:
Create a js file as follows and name it messages.js
var messages = {
"loading" : "Still loading",
"validation1" : "Please fill the required field",
"success" : "thats a success",
"failure" : "some error",
"custom1" : "custommsg1",
"custom2" : "custommsg2"
}
Include it in your web page and use whichever custom message you want to use
like for example
when you want to use success use message.success and similarily message.loading and so on for other messages.
Make sure that the left hand side values are unique since these are key value pairs.
There is nothing wrong that the user can see your wordings, and there is no way to hide data from user in web app. If you need to store secure data, keep them on the server, otherwise user can get from researching your app.
Create a JSON file called messages.json
and create a service to read from that by doing a HTTP request
$http.get("messages.json").then(function(response) {
$scope.messages = response.data;
});
Now scope has a property which is globally accessible
I am getting an error when I use JavaScript remoting and have my URLReWriter turned on on my Force.com SIte. The error does not occur when using JavaScript Remoting with the URL ReWriter turned off.
The error is as follows
Exception Error parsing json response: 'Unexpected token <'. Logged in?
I'm confused as to why this is occuring. If I have no checks for being logged in in my URL ReWriter (or visualforce page) why should this occur?
Has anyone ever come across something similar to this before? I noted the following https://salesforce.stackexchange.com/questions/4112/possible-oauth-remote-action-bug but in my case I am not using authentication on my site for the test page that I created & I'm wondering why it mentions "login".
Is it possible that URLRewriters and JavaScript Remoting currently do not work together in general?
Thanks in advance for any help on this.
Can you try debugging it server side? Add "your_site_name Guest User" to the debug logs and try the action. If you're lucky you'll see something going wrong (in the remote action? in rewriter?) and I suspect this uncaught problem causes a redirect to maintenance page (which will be HTML, not JSON)...
If not - use Firebug or similar tool to inspect request & response in detail? Or event.status?
Can it be something related to permissions? http://www.salesforce.com/us/developer/docs/pages/Content/pages_js_remoting.htm Or if you're returning html - I think you should have {escape:true}?
Does it happen in any browser? Maybe something doesn't like redirects caused by the URL rewriter. I've seen cases (not with Salesforce though) that antivirus software sometimes was adding some strange javascript at the end of certain websites and they had to be whitelisted...
The error may also happen due to parser error when page recieves status message from remote action function.
For example i tried Remote Action with attachment
#RemoteAction
public attachment attach(String body){
attachment a=new attachment();
a.body=body;
a.name='a.png'
insert a;
return a;
}
On the above code i receive error since SFDC does not parse the attachment object.SO if there are parser errors we get this message .
As a workaround i send as a wrapper .Hence i would suggest to investigate the return parameter of remote action and also wrapping it as workaround .
Hope this helps
i have a little problem with Meteor and Twitter.
All i want to do is posting a tweet through a click on a button. For this I have to authenticate myself over Oauth to the Twitterservice.
At the moment i am doing the authentification in a really complicated way springing from client to server and back. But now I found the function Meteor.loginWithTwitter. Originally I thought this function is only for logging you into your own application with the Twitterkeys, now i am not so sure anymore. Probably I can also use it for my problem. Because it seems that the Oauth-Process is completely (and in a simple way) implemented in Meteor.
Sadly i cann't find any documentation or examples for just logging in and getting the final oauth_token. And so all i got from Meteor back then i try the following code, is this errormessage:
Erromessage: Accounts.ConfigError {message: "Service not configured"}
Meteor.loginWithTwitter( function(err){
if (err){
console.log(err)
}else{
console.log("yeah");
}
});
I know i have to enter somewhere my Appinformation like the Consumer key, but i have no idea where. Can someone help me out and knows some examples for me? Or knows if i am even on the right track?
Thanks and greetings
Philipp
The easiest way of doing this: Add the accounts-ui package:
meteor add accounts-ui accounts-twitter
and in your template do
{{loginButtons}}
On the first start of the application, a click on the login button will guide you through the setup process. You will create a Twitter application and copy the consumer key and consumer secret into a form, that meteor presents you. Afterwards you can log in using Twitter.
Make sure to use the latest Meteor version (0.5.2 at this moment)
You can also config your consumer key and secret with code, this is an example with weibo but its work for twitter, google etc... (server side) :
// first, remove configuration entry in case service is already configured
Accounts.loginServiceConfiguration.remove({
service: "weibo"
});
Accounts.loginServiceConfiguration.insert({
service: "weibo",
clientId: "1292962797",
secret: "75a730b58f5691de5522789070c319bc"
});
You need to add what #Tom31 suggested in your server side, i.e., I have a /server/server.js
Accounts.loginServiceConfiguration.remove({"service": "twitter"});
Accounts.loginServiceConfiguration.insert({
"service": "twitter",
"consumerKey" : "<yours>",
"secret" : "<yours>"
});
Finally, your access token are stored in your user at the database but this information it is not propagated to the client and, if you want to have access to it, you new to create a server side method and access it through Meteor.call or Meteor.apply
Updated: Example of my server side method
I've created my server side method like this:
Meteor.methods({
...
userGet: function(id) {
return removeSensibleFields( Meteor.users.findOne({ _id: id }) );
}
...
});
where removeSensibleFields is a method to remove all unnecessary/private information that may not be sent back to the client