Code Monkey home page Code Monkey logo

Comments (4)

tikiatua avatar tikiatua commented on May 24, 2024

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.

tikiatua avatar tikiatua commented on May 24, 2024

P.S. Please take also a look at the example in the test directory for nested translation objects.

from vuex-i18n.

Remo avatar Remo commented on May 24, 2024

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 my Code English to English

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.

tikiatua avatar tikiatua commented on May 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.