AngularJS: Need language information in angularjs from language code - angularjs

In android, I am able to retrieve the language information from the language code itself using Locale class as shown below.
Locale locale = new Locale("fr");
locale.getDisplayName(locale); // Français
locale.getDisplayName(Locale.ENGLISH)); // French
I need the above information to be retrieved in angularjs from the language code alone. Is it possible to retrieve in HTML directly ?

A little late on this one, though there is a native API for this, window.Navigator.language.
For example:
console.log(window.Navigator.language); // 'en-US'

Related

Filestack - Does the file picker allow languages other than english?

I am writing a Javascript application for watermarking a photo. I want to know if the Filestack file picker supports languages other than English.
If you are using the Filepicker you can specify language in the 'lang' parameter of the pick function.
In order to make Spanish the default language for a picker you could use the following:
client.pick({
lang: 'es'
})
More languages are listed on the documentation https://www.filestack.com/docs/javascript-api/pick-v3
I was working for German Language, You can do this.
filepicker.picker({lang: "de"}).open()
with this your modal will look like this.
enter image description here

angular translate, how to get all the translate of one specific word in controller

I know that in controller I can use $translate.instant('HELLO_WORLD'), to get the translate to the 'current' set language.
What if the current is french, and I want to get english of 'HELLO_WORLD' too, but not changing the user's current preferred language.
The reason I want this is casue my app let user switch between french and english at any time. Everything works except for a directive that uses a $rootScope.object, the words inside doesnt get updated when user change the language.
The way Im trying to do it by is, I use a listener on this rootScope.object, when it get change, I manually change the item inside. However I need to know both french and english translate of each word to make the comparison and change.
The $translate.instant() API has a force language parameter. If you know your supported languages ahead of time you could query them all using separate calls to .instant().
instant(translationId, interpolateParams, interpolationId, forceLanguage, sanitizeStrategy)

Angular Translate: Use different fallback languages for specific locales

I want to support translations between e.g. different versions of English, but have a common fallback.
The following is an example of how the setup could be:
locales/en_AU.json
locales/en_US.json
locales/en.json
locales/fr_BE.json
locales/fr_FR.json
locales/fr.json
...
I want to have e.g. some Australian specific strings in en_AU.json, but have the rest in en.json.
In code I would like something like:
$translateProvider.fallbackLanguage(['en_*' : 'en', 'fr_*' : 'fr'])
Or to generally attempt to fallback to whatever is before the underscore.
I would also like to have a general fallback language
Is there a way to accomplish this?
I ended up listening for language changes, and if the new language key contained an underscore (eg. da_DK), I changed the fallback stack to be ['da','en'] and the called refresh.
$translate.use(languageKey);
// Check if language has a country code and add general language as fallback along with English
if (languageKey.indexOf('_') !== -1) {
$translate.fallbackLanguage([languageKey.substring(0,languageKey.indexOf('_')), 'en']);
}
$translate.refresh();
I'm using partial loaders and it didn't work for me initially. It loaded the language I changed to OK, but not the extra fallback language. The last $translate.refresh() was important

how to structure an asp.net app to have language in the address bar?

I want to have all addresses in my asp.net(web forms) application contain the selected language to allow search engines to index both language content. So I want it to be something like www.mysite.com/en/items/35
So what should I do to have it like that, I don't want to create page version for each of my language. I can set the page routing but how then I will understand what language to show in my page? should I analyse the address string and search for "/en/", "/ee/" and etc???
The easiest way is to use a rewriting engine so that the url
www.mysite.com/en/items/35
Is rewritten to:
www.mysite.com/items.aspx?lang=en&id=35
Then you simply write some code to look at the query string.

Titanium Mobile: set locale (language) in app

I don't quite get how the user locale is handled in Titanium Mobile.
I have now set up two language files, and at least the English version is working fine. Now I would like to be able to set the locale within the app, so a user may change the language of the app.
How is this done?
And what is the best way to handle other locale issues such as currency, date formatting, etc.?
Thanks you for your answers!
Cheers
Chris
Use and external JS library like https://github.com/fnando/i18n-js to be able to force switch language within app. The library is already quite robust.
http://i18njs.com/
For changing the language of the app you can try this, as I am using same for the same purpose :-
I have added this in alloy.js
var language = Ti.App.Properties.getString('selectedLanguage','es');
Alloy.Globals.language = language;
Ti.Locale.setLanguage(language);
for changing the app language, I have created a tableView for selection on table's click listener I am changing the app language
if(e.index == 0){
Alloy.Globals.language = 'es';
Ti.App.Properties.setString('selectedLanguage','es');
}else{
Alloy.Globals.language = 'en';
Ti.App.Properties.setString('selectedLanguage','en');
}
and after all that I am refreshing my screen, in my function updateScreenForLanguage();
function updateScreenForLanguage(){
$.Back.text = (L('Back'));
$.Title.text = (L('Profile'));
$.labelLanguagePreference.text = (L("Language_Preference"));
}
hope this will help you. for more Titanium internationalization
You can use below modules
https://marketplace.appcelerator.com/listing?q=locale%20-#!/list/page/1/search=locale%20-
This modules helps you to follow same i18n folder string.xml and it will force the language only inside your app.
Titanium language locale can be use like this
var language = Titanium.Platform.locale;
Titanium.App.Properties.setString('locale',language);
Titanium.App.language = language;

Resources