GithubHelp home page GithubHelp logo

Comments (22)

DWand avatar DWand commented on May 22, 2024

Two more thoughts. What about
a) comments
"key": "translation", // context
b) arrays
"key": ["translation", "context"],
as a variant

from angular-translate.

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

@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.

knalli avatar knalli commented on May 22, 2024

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.

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

@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.

lichtner avatar lichtner commented on May 22, 2024

@PascalPrecht @knalli sorry guys I misunderstand this example.

from angular-translate.

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

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.

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

@DWand In both, a) and b) you don't have any connection between translation-id <-> context <-> translation

from angular-translate.

lichtner avatar lichtner commented on May 22, 2024

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.

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

@lichtner But no matter what, you need this context feature?

from angular-translate.

DWand avatar DWand commented on May 22, 2024

@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.

lichtner avatar lichtner commented on May 22, 2024

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.

lichtner avatar lichtner commented on May 22, 2024

this was reason why I start this talk.

from angular-translate.

lichtner avatar lichtner commented on May 22, 2024

@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.

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

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.

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

@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.

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

@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.

lichtner avatar lichtner commented on May 22, 2024

If I do some experiments with some translation tool I will send you feedback.

from angular-translate.

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

Do that! :)

from angular-translate.

lichtner avatar lichtner commented on May 22, 2024

;)

from angular-translate.

DWand avatar DWand commented on May 22, 2024

@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.

DWand avatar DWand commented on May 22, 2024

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.

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

Closing this for now

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.