Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

supporting i18n #1

Open
flipflopsimsommer opened this issue Jun 2, 2014 · 3 comments
Open

supporting i18n #1

flipflopsimsommer opened this issue Jun 2, 2014 · 3 comments

Comments

@flipflopsimsommer
Copy link

supporting multi language is something important for cms.

/config/i18n.js

module.exports.i18n = {
  // Which locales are supported?
  locales: ['en', 'de', 'it'],
  // Where are your locale translations located?
  localesDirectory: '/config/locales'
};

in your policie:

var locale = undefined;
if(typeof req.session.user == 'object' && typeof req.session.user.locale !== 'undefined'){
    locale = req.session.user.locale;
    sails.log.info('choos language in profile ' + locale);
}
return ok();

then you just use res.__('test')

enable autoupdate in lang.json file.

@hayksaakian
Copy link
Owner

If balderdashy/sails accepts the pull, i think i could work this in

one problem i see is:

if the visitor to the website is not logged in as a user, the locale will never be set.

@flipflopsimsommer
Copy link
Author

i hope the accept it soon, it's only 1 line and by default nothing chances.
as i understand and combined with my code it would work something linke this

  • it uses the defaultLocale in your i18n.js config file
  • if sent it will use the http header: Accept-Language.
  • if set it uses the session locale.

okey just realised i should past the defaultLocale as well
i will make a new pull request sails

@flipflopsimsommer
Copy link
Author

updated the url to the new pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants