setting i18n locale

18 views
Skip to first unread message

Kris Wolff

unread,
Jul 12, 2015, 4:00:03 AM7/12/15
to apostr...@googlegroups.com
Hi, 

i ran into some problems with i18n. I think it is a configuration problem on my side, and i am also sure you can point me into the right direction. 
 
Steps i've made:
- beside de en.json language file, i put a de.json file into ./locales
- In var site = require('apostrophe-site')({ i overwrite i18n:
, i18n: { locales: ['de', 'en']
, cookie: 'apos_language'
, directory: __dirname + '/locales'
, defaultLocale: 'de'
    }
- and in the middleware of my language switcher i set the cookie:
res.cookie('apos_language', req.session.language, { maxAge: 900000, httpOnly: false });

The cookie is set correctly to "de" and "en", but the text does not change it langauge at all for all the translated __('') terms. 

some hints for me?

Thanks, 
kris

signature.asc

Tom Boutell

unread,
Jul 13, 2015, 8:11:29 AM7/13/15
to apostr...@googlegroups.com
I'm not sure what the issue is. Danny Pavolotski wrote this code. Danny, are you tuning in?

--
You received this message because you are subscribed to the Google Groups "apostrophenow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to apostropheno...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--


THOMAS BOUTELL, DEV & OPS
P'UNK AVENUE | (215) 755-1330  |  punkave.com

Kris Wolff

unread,
Jul 13, 2015, 10:00:41 AM7/13/15
to apostr...@googlegroups.com
I loged i18nOptions in ./node_modules/apostrophe-site/index.js and my config is set correctly.
that goes into i18n.configure(i18nOptions);

I can't see any issues why this is not working. but it doesn't. strange thing. Never got these issues with i18n before. (used it a lot in different projects) 


But than... wait... all my translations are set back. WHAT? 

So i update my conf and said: 
      updateFiles: false

this prevent the files for any updates. The downside is that i have to set every string in development by hand. But that is ok for me. 

The question is still: why does i18n updates my translation files completely and overwrites the default hint. But anyway this is a i18n Issue I have to dig in some day. 



signature.asc

Tom Boutell

unread,
Jul 13, 2015, 12:09:10 PM7/13/15
to apostr...@googlegroups.com
For what it's worth, I just did a global find in my sandbox-05 project and didn't come across any code at all that sets req.locale. I'm not sure there is any middleware for this "out of the box."

I'll be including some in the apostrophe-i18n module, which I'm busy working on right now; it's for content localization primarily, but it will include a culture picker and the middleware.
Reply all
Reply to author
Forward
0 new messages