Giter VIP home page Giter VIP logo

Comments (18)

lichtner avatar lichtner commented on May 13, 2024

I would like to ask you, "context" are supported? Especially in English many words have many different meanings so it leads to ambiguities and translator cannot able to translate every word in correct meaning (I have many experiences with it). Can I define some "context - explaining note" (e.g. as it is in gettext) for some translations if it is important?

from angular-translate.

knalli avatar knalli commented on May 13, 2024

Should not this be handled by the key or namespace?

from angular-translate.

0x-r4bbit avatar 0x-r4bbit commented on May 13, 2024

@lichtner I already saw such a thing in another implementation for i18n and asked myself, what the hell these "descriptions" are, why they were there and for what these are used. Now things become a bit clear.

So, I'm not familiar with the gettext implementation, could you give a little example on how these descriptions work and how they're used in theory?

from angular-translate.

lichtner avatar lichtner commented on May 13, 2024

@knalli may be key can be used as description.

@PascalPrecht if you were a translator and should translate e.g. word "date" how to translate it without if you don't know context where this word was used? It is label for "metting" or some "date of a day"?

Gettext use this four functions in source code e.g. in php:

gettext($message)  // Translate a message.
ngettext($singular, $plural, $count) // Plural version of gettext.
pgettext($context, $message)  // gettext with contect.
npgettext($context, $singular, $plural, $count) // Plural version of gettext with context.

// examples
gettext('Hello world');
ngettext('%s item', '%s items', 3);
pgettext('date as a term', 'date');

Silly names of functions ;-) Gettext use primary language as a key but it does not matter. But as @knalli said key can contain some description. But it could be problem if I try to use some translation tool. Because context is important only for max 5-10% of strings and if I try to use some tool I should convert all keys as a context, but in most cases it could be useless.

May by small improvement of $translateProvider format can solve it:

$translateProvider.translations({
    'simple-text': 'Simple text',
    'text-with-different-meanings': {context: 'some description', text: 'date'}
  });

So if I create some translation tool I can show context only if it is important. What do you think about it?

from angular-translate.

0x-r4bbit avatar 0x-r4bbit commented on May 13, 2024

Still trying to get it. So when exactly do descriptions come in? Are these checked again something else or something? Or is it just a side information for a translator?

from angular-translate.

0x-r4bbit avatar 0x-r4bbit commented on May 13, 2024

If the latter, then yeah.. we could actually implement this context key as additional feature. If I'm getting this right, you actually already have a descriptive translation id, I mean, that should be the case.

But maybe there are cases where you aren't able to decide how to name translation id's. In that cases it'd be very helpful to have a chance to get something like a description in.

So yeah, why not? :)

from angular-translate.

lichtner avatar lichtner commented on May 13, 2024

right it is only additional side information for translator

from angular-translate.

knalli avatar knalli commented on May 13, 2024

In other words: If value is not a string but an object, we will treat the object's property text as the value? The context will be technically irrelevant?

Actually, this will potential break the namespacing feature. It is conflicting.

from angular-translate.

0x-r4bbit avatar 0x-r4bbit commented on May 13, 2024

@knalli Yeap, and this means, context could be anything. And doesn't even be named context since it depends on the tool you use, to get the descriptions...

from angular-translate.

lichtner avatar lichtner commented on May 13, 2024

@knalli exactly so. context is only for translator, for you is irrelevant. You use only text property.

from angular-translate.

knalli avatar knalli commented on May 13, 2024

What if I want this here:

$translateProvider.translations({
  "dialog": {
    "title": "Form",
    "context": "Context",
    "text": "Please confirm..."
  }
});

For standard usage

  <div>
    <h2>{{'dialog.title' | translate}}} ({{'dialog.context' | translate}})</h2>
   <p>{{'dialog.text' | translate}}</p>
  </div>

from angular-translate.

lichtner avatar lichtner commented on May 13, 2024

gettext don't use keys and don't have any translatorProvider table. Gettext have a scanner which scan source code and extract translations to file. So gettext have to put context into source. But you don't. For you is enough if context is in $translateProvider.

from angular-translate.

0x-r4bbit avatar 0x-r4bbit commented on May 13, 2024

@knalli @lichtner These are just 2-3 lines of code to implement this, without breaking the existing behavior. I'm not sure if there's a performance issue when there's a high amount of translations, since we have to add another check.

from angular-translate.

0x-r4bbit avatar 0x-r4bbit commented on May 13, 2024

@knalli If we go with context, it's a 'reseved' word/key I would say.

from angular-translate.

lichtner avatar lichtner commented on May 13, 2024

@knalli this is not problem:

$translateProvider.translations({
  "dialog": {
    "title": "Form",
    "context": { context: "description of context", text: 'Context' } ,
    "text": "Please confirm..."
  }
});

from angular-translate.

knalli avatar knalli commented on May 13, 2024

? :) Ehh..

from angular-translate.

lichtner avatar lichtner commented on May 13, 2024

may be it will be performance problem because you have to test if translation is string or array

from angular-translate.

0x-r4bbit avatar 0x-r4bbit commented on May 13, 2024

Let's discuss on that here: #57

Don't wanna pollute this one here to much :)

from angular-translate.

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.