Comments (15)
Adding a msg
property that notifies sounds like a good idea to me! Want to propose a PR?
from i18n-msg.
Yes, I do the PR as soon as possible !
Thank you for your answer
from i18n-msg.
+1 - This would be a great way to simplify usage!
@ebidel - What do you think about pushing this further by exposing all localized messages of the current language via a Behavior
? Elements with this behavior would get a property i18n
(type Object).
For example to access the localized value for key "paper_label" from within an element with this behavior:
<paper-input label="[[i18n.paper_label]]"></paper-input>
This would significantly simplify using the localized values in methods.
from i18n-msg.
Yeah it is a good idea, and the original i18n-msg element could use this behavior.
Maybe it is better than the msg property because we will not have to insert an i18n-msg element on each attribute.
from i18n-msg.
@RoXuS and @ebidel : did you roll out the changes for attributes i am also looking for it as i am using this awesome element
from i18n-msg.
@sumukhj84 - I don't think it did.
We actually ended up creating our own i18n-behavior that exposes the translations as properties. I also wrote a blog post about it with some additional background: https://medium.com/collaborne-engineering/localize-polymer-applications-216e8bc90e1a
from i18n-msg.
@sumukhj84 I do the PR see #28.
But for now I have no news from @ebidel.
from i18n-msg.
@ronnyroeller I like the idea of a behavior that elements can use. Want to prototype it in a new PR?
Taking a look at @#28
from i18n-msg.
@ronnyroeller i like the idea but i have few questions after reading your blog :
- Is the JS file used for any language is per element basis like you wrote my-element.en.i18n.js, my-element.de.i18n.js?
- Are these JS files get loaded in the polymer app on demand or at the first request all JS files for each language will be loaded once?
- So if i have 6 languages to support then i must create 6 language JS files per element so if for example i have 6 elements then 36 JS files will be required? I am confused here.
- Is this element has support to IE10 or IE11? As many of our user use these browsers.
- Is this element Production ready?
from i18n-msg.
@sumukhj84 to your questions:
- Yes, we prefer having the localizations per element as this makes it easier to distribute the development of the elements over various teams/repositories. We use tools to combine all texts before sending them to our translation agency, and then afterwards distribute the translated content to the element-specific i18n files.
- All localizations are currently loaded when the element is loaded. It would certainly make sense to load them on demand instead (just not a requirement for us right now).
- Yes, that's right.
vulcanize
puts all files together during the build, i.e. in the end it's all part of the final distribution file. - We officially support IE11+ for our customers but I don't see a reason why it wouldn't work with IE10.
- We have been using it in production for a while.
Let me highlight the last point of my blog post: "I wish I wouldn’t have to write this post. Hence: Please, PolymerElements team, get out the carbon elements! :) For the time being, our open sourced carbon-i18n-behavior might help some folks localizing their Polymer applications." - So this is really just a lightweight solution until the Polymer team brings out the "official" i18n behavior. That's one of the reason why we don't use the JS files as the raw format of the translations. Instead we generate them from the XLIFF files which we exchange with our translations agency (see https://medium.com/collaborne-engineering/localize-polymer-applications-with-a-translation-agency-b3291b574c85).
Hence, our i18n behavior does only the bare minimum. Feel free to extend it to your own needs.
[PS: Sorry, as this response is a bit off topic to the initial ticket.]
from i18n-msg.
@ebidel - Absolutely. We'd rather contributing to an existing elements instead of creating & maintaining our own elements.
Along those lines: it would be really helpful if the Polymer team could provide a bit more transparency regarding the "official" i18n support that was announced back at the Amsterdam summit. Knowing when it's expected to be available and how it's going to look like would help us to put temporary solutions in place from which it's easy to migrate afterwards. Just my two cents :)
from i18n-msg.
@ebidel, @ronnyroeller I have a simple example with i18n behavior.
The i18n-msg works perfectly (demo+tests) with this behavior :
https://github.com/RoXuS/i18n-msg/blob/behavior/i18n-msg.html
I have made a component which use this behavior to get translations :
https://github.com/RoXuS/i18n-msg/blob/behavior/i18n-page-example.html
It's not completely finish but a good start pending the Polymer component.
from i18n-msg.
Hi @RoXuS I've sent you a pull request to the changes that you made. I like what the behavior adds and it makes things pretty nice to work with. I've moved more of the functionality into the behavior which removes most of the boilerplate.
Updated example element: https://github.com/Zoramite/i18n-msg/blob/behavior/demo/i18n-msg-behavior-example.html
Now it just requires adding the behavior and defining the message ids in the properties and the behavior takes care of the rest.
from i18n-msg.
Hi @Zoramite thanks for your work !
Yes I had left the option to use any property name, but you're right, perhaps it is better to limit the boilerplate.
I added this commit to add the new name of the example in the all-import.html script.
from i18n-msg.
Think this is fixed in #28
from i18n-msg.
Related Issues (16)
- Add event to know when xhr is done
- I can't change language back
- Bind to attributes HOT 9
- Make messagesDir settable on global I18nMsg object HOT 1
- Use element content as msgid HOT 1
- My try to extend the concept HOT 8
- not loading translation when using in dom-repeat (giving msgid value by data-binding) HOT 6
- i18n-language-ready never fires under polyfill HOT 1
- console error if I18nMsg.url changed (still goes to default locales url?) HOT 4
- i18n-msg doesn't work in FF and Edge. HOT 2
- Add support for placeholders HOT 1
- 'messages-url' not overriding default value
- 'Object.observe' is deprecated HOT 1
- is this the l10n/i18n solution from polymer roadmap? HOT 1
- Is it currently possible to translate input placeholders?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from i18n-msg.