Comments (18)
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.
Should not this be handled by the key or namespace?
from angular-translate.
@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.
@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.
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.
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.
right it is only additional side information for translator
from angular-translate.
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.
@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.
@knalli exactly so. context
is only for translator, for you is irrelevant. You use only text
property.
from angular-translate.
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.
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.
@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.
@knalli If we go with context
, it's a 'reseved' word/key I would say.
from angular-translate.
@knalli this is not problem:
$translateProvider.translations({
"dialog": {
"title": "Form",
"context": { context: "description of context", text: 'Context' } ,
"text": "Please confirm..."
}
});
from angular-translate.
? :) Ehh..
from angular-translate.
may be it will be performance problem because you have to test if translation is string or array
from angular-translate.
Let's discuss on that here: #57
Don't wanna pollute this one here to much :)
from angular-translate.
Related Issues (20)
- Use templated string as key HOT 1
- bower repo doesn't have latest release tag HOT 3
- De-cloaking broken in 2.18.2 HOT 4
- Default interpolationParams allows access to function constructor HOT 1
- translate dynamic content loaded with ajax HOT 1
- How to use UI router with angular translate? HOT 1
- [email protected] support HOT 5
- translate-sanitize-strategy HOT 4
- “SameSite” attribute warning HOT 1
- Not changing languages on ng-click
- Cookie “NG_TRANSLATE_LANG_KEY” will be soon rejected because it has the “SameSite” attribute set to “None” or an invalid value, without the “secure” attribute. HOT 9
- Two Languages at same time HOT 1
- IOS cordova When i upgrade the AngularJs to 1.8.2 the words will be missed which was been translated. HOT 1
- Using AngularJS Filters with Pluralization via MessageFormat HOT 1
- $translatePartialLoader.doesnot allow ë à á characters HOT 4
- $translate.instant with angular expression HOT 1
- Unexpected behavior registering translations with .translations() and using an async loader with .forceAsyncReload(true) HOT 3
- Partial loading can fail silently without any hints HOT 1
- $translateStaticFilesLoader should behave gracefully when one of translations cannot be loaded HOT 1
- Team awareness required: Future project state HOT 7
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 angular-translate.