Comments (22)
Two more thoughts. What about
a) comments
"key": "translation", // context
b) arrays
"key": ["translation", "context"],
as a variant
from angular-translate.
@lichtner regarding this one: #13 (comment)
This would mean, everytime you have a namespace context
and don't actually mean 'our' context
you have to make a hash of it, which has a text
key. Could look a bit weird right?
from angular-translate.
My concerns about this are
1 Required introducing of reserved keys
This example will not work any more if the feature would be introduced because the translation reader could not handle both
$translateProvider.translations({
"dialog": {
"title": "Form",
"context": "Context",
"text": "Please confirm..."
}
});
<div>
<h2>{{'dialog.title' | translate}}} ({{'dialog.context' | translate}})</h2>
<p>{{'dialog.text' | translate}}</p>
</div>
2 What about recursions?
$translateProvider.translations({
"dialog": {
"title": "Form",
"context": {
"context" : {
"text": "Text"
}
}
"text": "Please confirm..."
}
});
Allowed? What is expected? What should we do?
3 In combination to the given points, additional hints like comments will bloat them even more up. IMO :)
from angular-translate.
@knalli Agree with you. @lichtner do you have already such a tool, which collects translation ids and show up descriptions in some way? Or do you plan to build one?
If there's already a tool, it'd be interesting what it actually expects to get descriptions out of translation tables (something beside gettext, something with UI 'n stuff like that, for the translator you know :) )
from angular-translate.
@PascalPrecht @knalli sorry guys I misunderstand this example.
from angular-translate.
We get some conflicts with a kinda reserved keyword like context
which only makes sense in a object hash which has to be detected by angular-translate, since $translateProvider.translations()
is also able to understand namespaces.
from angular-translate.
@DWand In both, a) and b) you don't have any connection between translation-id <-> context <-> translation
from angular-translate.
I am not sure if I will build new translation tool or if I build convert script from your format to some format which can I import to existing tools.
from angular-translate.
@lichtner But no matter what, you need this context feature?
from angular-translate.
@PascalPrecht, ok. But what kind of the connection is needed?
If we have
$translateProvider.translations({
"dialog": {
"title": "Form",
"context": "Context",
"text": "Please confirm..."
}
});
, is the given "contex" a context for "title", "text" of for a whole parent-object?
from angular-translate.
Now I develop new ng-app. In my previous apps (non ng) I need it and I used it. May be I will need also, now I am not sure. IMHO it is common feature for translation tools so I can help you develop better tool.
from angular-translate.
this was reason why I start this talk.
from angular-translate.
@DWand may be comment will be enough if javascript have some annotation which I can get via some reflection. But I don't now it annotation exists in javascript, do you know? Or I can create some comments scanner.
from angular-translate.
This is where it's getting tricky. This would just be resolved to:
dialog.title // 'Form'
dialog.context // 'Context'
dialog.text // 'Please confirm...'
Now, when actually wanna have context for a specific translation id you would do something like this:
.translations({
'dialog': {
'context': 'This is a description',
text: 'This is the actual translation'
}
});
So this:
"dialog": {
"title": "Form",
"context": "Context",
"text": "Please confirm..."
}
Wouldn't work anymore, since we would check something like "if translation id is object and object.context is truthy, use object.text". In that case, dialog.title
is just out of the race.
from angular-translate.
@lichtner it just depends on what your tool would expect. If you wanna go with comments, do comments (with annotations). These comments will be ignored by angular-translate, but your tool has to know, how to handle'em. So in case of using comments for that, this is no longer a work of angular-translate.
from angular-translate.
@lichtner Nevertheless, it'd be cool to say that angular-translate would work well with such a tool. So I'm open for solution ideas. :)
from angular-translate.
If I do some experiments with some translation tool I will send you feedback.
from angular-translate.
Do that! :)
from angular-translate.
;)
from angular-translate.
@lichtner, I don't know. But it seems no. It's hardly true that js has such functionality.
It's hardly depends on a "tool" you all are talking about. If it is a desktop app you could write some kind of parser for comments. All you need is to provide a convention of placing those comments.
But, nevertheless, I think, if you, guys, really want to extend/improve this module qualitatively, you have firstly to look how this feature is implemented in another products which are greatly comfy to use. Maybe, it can help to find a right way.
from angular-translate.
And yes, just one more thought.
If this feature is only for the translator and is never showed to the user, why do you want to write this context to the translation tables? JS is not a PHP, Python, Ruby or so on. User has to download this translations on local machine. And any additional symbol in the translations reflects on the loading time.
At the same time, the translator works on the server side. And he works with sources of translations. So, how exactly this feature in the JS module can help the translator on his local machine?
Maybe, it's better to use a specific formats of a used tool to store translations on the dev machine and simply convert/compile the resulting translation to the needed format of the JS module? As for me, this approach is much better. It's very hard to adapt this module to all possible translation tools. And, even if it's possible, the module will looks like a monster instead of tiny comfy pretty useful thing.
Excuse me, please. Maybe, I'm wrong. Maybe, I don't get something. But my opinion is that JS module has to be independent from the tools you use to translate texts in the backend. It simply has to show user a correct text in correct language which is predefined before. Actually, this is not an IDE, isn't it?
from angular-translate.
Closing this for now
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.