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
Multiple namespaces not rendering on client. #199
Comments
what is and why you use the node backend on the client? change that to the xhr backend... |
Sorry @jamuhl I got those code blocks muddled up. I've fixed them.
Apologies if this isn't the correct place! Within the client.js the |
is resources filled with the needed translations? might be that was assigned before backend loaded resources? else idk...rather sure the |
I checked this issue and it seems to similar to what I'm experiencing! |
i'm not much into this...but if your page uses the namespace |
closing this as i expect it to be solved - otherwise feel free to reopen. |
I'm finding the examples quite lacking in this regard / the universal hot render example is clearly avoiding this issue to get it to work.
client & server need updated ns
on server need to do some sort of accumulation of resources, unfortunately clearly not integrated with react-router so any collisions across namespaces are kindof unavoidable, unless you assign based on namespaces (which would make much more sense)
|
like mentioned earlier...personally i do not have a project that uses universal rendering - as we do not profit of that (authorization, websockets, ...). But i would love someone taking the time to make a improved example: but looking at https://github.com/ipatate/UniversalAppReact/blob/master/package.json might be good starting point? Suggestions are welcome to improve... |
To be honest I looked at that project and it also doesn't solve the issue of translation splitting. I'm likely to just write my own library - as this one doesn't seem to architecturally tie a namespace to a react component (which is something I'd like, and would make integration with something like react-router much easier) |
Cool...would be great to see you're version - you plan to write a wrapper around i18next - or icu format? Send me a link to your repo as soon as possible...thank you. |
Well I'm trying to get it to be a bit more lightweight - although I'm not
very experienced with internationalization standards / options so I'm sure
I'm making mistakes. I'm thinking of writing Polyglot.js Provider a bit
like https://github.com/nayaabkhan/react-polyglot/blob/master/src/i18n.js
which provides both translations, Polyglot helper functions and the current
language and extending the translations per component using a HOC that is
passed a local javascript object (which has lots of keys that map to either strings or functions or react components or polyglot objects) that is exported from a translations file
inside the component folder.
…On Wed, Feb 22, 2017 at 12:56 PM, Jan Mühlemann ***@***.***> wrote:
Cool...would be great to see you're version - you plan to write a wrapper
around i18next - or icu format? Send me a link to your repo as soon as
possible...thank you.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#199 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAlhcHN2MDMlyDsnq1gyE6yZ4giPmMHcks5rfDCVgaJpZM4Jr4Np>
.
|
looking forward to it... |
@davidfurlong I'm dealing with the same problem if I understood you correctly. I've just written down my ideas in |
@tricoder42 Yes, so I wrote a little (very naive) way of doing that isn't good enough (https://github.com/davidfurlong/react-local-translations) - as I was trying to avoid having to add more API surface area on my react code. But I am totally on board with what you are saying. If local CSS is a good idea, then surely so is local translation files. Ofcourse having a build process to unify them would be useful for handing to translators (this is a pain with local translations), but it also means that you can add / remove components really quickly and not worry about global namespace. It also solves the issue of having huge translation files being loaded into your bundle. I tried using this repo and (without benchmarking) I could see a noticeable performance hit, so I'm trying to keep what I build minimal (for the vast majority of translations, things like pluralization or other helper utilities aren't needed). I'm about to start writing a basic version of this, and I think it'll be pretty quick. But I'm still uncertain of what i18n library to use |
@tricoder42 Why did you decide to use react components to wrap translations rather than using either a key or functions? - I think passing the choice of how to structure the either string or react component should be passed along into the individual translations Also heads up example-usecase link on the readme is broken link https://github.com/lingui/js-lingui/blob/master/packages/example-usecase/src/Usecase.js |
Also thanks for writing js-lingui it looks much more minimal and along the lines of what I was looking for |
What we basically do in our projects (and those are huge user applications managing access control) is we pass down a t function to components consumed from our shared libraries - as we manage namespace files using locize.com service - we do not have to create them multiple time...but this might be luxury. |
and agree i18next might be a little bigger in size - as it's more than a translation function (backend, cache, lng-detection, flexibility) all comes with a price - but the benefit is - i18next will be usable when nobody will use react anymore - as the next better framework arised ;) and don't get me wrong...i like what @tricoder42 did with js-lingui. Use whatever suits your need best. |
@davidfurlong Don't want to hijack this thread, so I answered your question here: lingui/js-lingui#15 Also, thanks for the report. Readme is fixed now 👍 |
I have my
common.json
file being pulled into Jade template files which are working fine, but I can add another namespace and have it work correctly, it keeps getting overwritten, and the resources is not added within thewindow.__i18n
object.Here's my
i18n-server.js
and the
i18n-client.js
I also have this within my
client.js
fileAnd this is my
server.js
fileAnd i18n is picking up my
homepage.json
file and it renders in the jade file (as=t('homepage:test.title')
at first but then gets overwritten because it's not in thewindow.__i18n
resources. What am I missing!The text was updated successfully, but these errors were encountered: