Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to list all requirable languages #147

Open
Elindorath opened this issue Nov 14, 2016 · 3 comments
Open

Add a way to list all requirable languages #147

Elindorath opened this issue Nov 14, 2016 · 3 comments

Comments

@Elindorath
Copy link

Hi tinganho,

I use l10ns for a mobile app translated in five languages.
I have to find the available language closest to the one of the phone.
For now, I just compare the two first letters, falling back to en-US by default.

In order to do so, I would find very useful if we had a way to list all supported languages (the five ones for my case). I proposed this #144 to do that, and here is the issue you requested.

You should notice that I put the function listLanguages beside requireLocalizations which give us a getter, not a localized string.

On an API design side, I am not completely satisfied, but it could open the way to more utilitaries functions. If I had a configuration file to parse that would contains the available languages, I would not need this feature.

@tinganho
Copy link
Owner

Still this is more suitable for an external library. It shouldn't be part of L10ns. I think there should be some library that does some language acceptance for your platform right now.

@Elindorath
Copy link
Author

Ok, there is something I probably missed, so let me summarize:
I have my codebase using the getter l('SOME_KEY').
Then I perform l10ns update to add all new keys.
With l10ns set ref -l lang value, I match value with the key for the given lang.
Finally, l10ns compile create all.js (and all lang.js).

All these operations are performed by multiple team members at different time and the result is stored on a git repository. This result is evolving all the time, so I have to decide at execution what is the best option on a given context (the phone language in that case).

The information I need is store on two locations:

  • In the name of all lang.js files
  • In the code of all.js

So I only see two options to do what I want:

  • List all the lang.js files (unfeasible on browser)
  • Add a function in all.js aware of the l10ns configuration

Maybe a third possibility where I get all.js in a string format and parse it, but this seems to be a little bit painful.

I don't really understand how an external library could help me on this.

Pardon me for insisting but I hate not understanding.

@tinganho tinganho reopened this Nov 14, 2016
@tinganho
Copy link
Owner

The way I do it is to duplicate all languages I have written in l10ns.json on to some source files. Though it requires duplicate work.

It might make sense to compile it directly on the output file. I think I need some time to reflect on this first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants