Closed kgardnr closed 7 years ago
If no one is working on this yet I would like do so
Welcome @PepeFranco! Thank you - it's all yours! :)
Hey @wyattjoh ,
I have some doubts regarding this. I'm just getting familiarized with the code. I understand I need to initialize a variable on config that pulls from env variables. I can then export it on routes/static.js and load it to bootstrap via getStaticConfiguration method.
If I'm not mistaken the i18n.js file which manages translations sets a default locale from either local storage, navigator or defaults to english when it is first required. It makes sense to me then that on the initialization it should pull the environment variable (if any) and default to that. To do so can I refer to it simply by process.env or should I import the getStaticConfiguration method from the bootstrap file to properly get this variable?
Or is there a way to pass the default variable loaded on bootstrap to the i18n file, say from local storage or the redux store?
Let me know if this makes sense or if I should clarify something.
Hey @PepeFranco.
After further reviewing, I think it may be best to expose it at build time.
Checkout https://github.com/coralproject/talk/blob/1ba5fd0028517b4ec9b3e75b4371f7506082edd3/webpack.config.js#L111-L114 and add the TALK_DEFAULT_LANG
variable, and replace https://github.com/coralproject/talk/blob/197d94ffb1978d038a641996ef1a9146c2f32133/client/coral-framework/services/i18n.js#L16 with process.env.TALK_DEFAULT_LANG
.
For extra points, document the new variable in our docs. Checkout our docs and add the new variable under the advanced configuration
page. If you have questions, feel free to ping me again here :smile:
Fixed in #1053
Hi @wyattjoh I'm a developer from WSJ and we are developing the CN version of WSJ. So I'm following the instructions in the doc to get talk in Chinese, but after the image built and run, it's still in English. My Dockerfile is as follows:
FROM coralproject/talk:4.3.2
COPY . /usr/src/app ENV TALK_DISABLE_EMBED_POLYFILL TRUE ARG TALK_DEFAULT_LANG=zh_CN # Also tried # ENV TALK_DEFAULT_LANG=zh_CN
RUN yarn config set registry http://production.npmserver.virginia.onservo.com && \ cli plugins reconcile && \ yarn && \ yarn build && \ yarn cache clean
CMD ["./bin/cli-serve", "-j", "-w", "--disabled-jobs", "mailer"]
Am I doing something wrong or missing something? Many thanks!
It may be the case that your web browser is still sending the wrong language to Talk, as it will try to get the browsers current language when you load the page.
AC: