Comments (4)
Hi @Remo,
I am not sure if I understand your question correctly, but what I get from the gettext documentation is the scenario where you have the same string that should be translated differently depending the context that it is required.
As example: The text "open file" should once be translated as "open a file from your system" and the other time just as "open".
In my opinion the solution specified in gettext might be more convenient to the translating person. But I would want to make the case, that the required translations should be specified as exactly as possible in the code.
Basically you could implement it as follows (using a key as identifier for the translations):
// translations
const translationsEn = {
"open": "open a file from your system"
"open.short: "open"
}
// using it like so
<p>{{ 'open' | translate }}</p>
<p>{{ 'open.short' | translate }}</p>
This would give the developer full control of whether or not to use the long or short string and still keep the translations next to each other to be easier to translate.
Please let me know, if you see a problem with this approach.
from vuex-i18n.
P.S. Please take also a look at the example in the test directory for nested translation objects.
from vuex-i18n.
Thanks for the detailed answer @tikiatua!
You're saying that we can use an identifier for the translations which can make sense in some cases. Coming from a gettext background I'm used to have the full English version in my translation tool, but that's probably more a habit than anything else. Either way has some benefits I guess.
If we use identifiers, we can build nested translation keys like you're showing, that allows us to group things nicely, but I have some doubts. This approach creates some kind of hierarchy which I believe can be useful, but maybe for something else. If we had a bigger application we could structure the translations to give the translator a bit more context, for example patient.name
. However, even within patient
I might have the word No
to translate which can either be Nr
or Nein
. I would then have to add another structure at the end patient.no.number
which I guess should work, but eventually gives me a chaotic structure. I'd like to have a system that works in all cases when I use identifiers instead of sentences, otherwise you'll end up with a mess if you have a few developers working on your system.
Separating the context from the identifier has another benefit though, forgive me my bias because of gettext.
Languages aren't my strong suit, I usually need help from someone and then run into situations where I have to change the code to separate a sentence/identifier. If I just add a context, my PO translation tool still knows, that the actual string is the same. The translator sees a suggestions based on the string without the context. This can be helpful, but it's certainly not a deal breaker.
In other words:
- I like to be able to use a hierarchy and add a context as a different dimension. This is just a minor, nice to have.
- I don't need a context if I use identifiers, but it starts to fall apart once I want to keep complete sentences in my code. This is almost a deal-breaker. I could of course add something to my sentences
No (Number)
, but I'd lose the translations and I'd have to start translating myCode English
toEnglish
I'll think about this for a bit, but I guess if we use identifiers I give your library a shot, otherwise I'll probably go with something else.
from vuex-i18n.
I will close the issue for now. As the discussed functionality is way more complex then what is currently possible with the plugin.
from vuex-i18n.
Related Issues (20)
- Support for yarn HOT 1
- What is the current version? HOT 3
- The v1.10.7 introduced a couple of breaking changes: Comparison vs v1.10.5 HOT 5
- Not able to access i18 plugin from mutation in classic mode store in Nuxt application HOT 1
- Usage of special characters inside the translations ( ) HOT 2
- Testing the fallback language - Chai HOT 2
- Single File Component Children not updating HOT 3
- Hook custom logic for non existent keys in lang HOT 2
- nuxt example implementation HOT 2
- Improve typescript declarations HOT 3
- Improve plugin documentation
- Multiple modules HOT 2
- What about provide plugin for debugging content HOT 1
- Using square brackets in identifier does not work HOT 2
- Linked local messages HOT 1
- Set Fallback language File HOT 5
- How to translate a component attribute/property
- Unicode-Support?
- support change language key before render ?
- Option to suppress the `i18n: Not all placeholders found` console warnings HOT 1
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 vuex-i18n.