Where can I define the default i18n language in JHipster? - angularjs

I am new to JHipster and I would like to where can I define the default i18n language in JHipster? Is it in a Java Configuration class, in Spring-Boot yaml file, or in Javascript file?

You can set the language you like in the weapp/scripts/app.js file by changing the preferred language line, for instance $translateProvider.preferredLanguage('fr');changes the language to french.

And for JHipster 5.7.2 it's in src/main/webapp/app/app.module.ts under defaultI18nLang.

In the newer version of Jhipster (v 3.0.0 - the one I've been using), you will need to change two places:
src/main/webapp/app/blocks/config/translation.config.js: change the line $translateProvider.preferredLanguage('en'); with your preferred language key (e.g. 'en' -> 'fr');
src/main/webapp/app/blocks/config/translation-storage.provider.js: change the line $cookies.putObject(name, 'en'); with your preferred language key as well.

For jhipster: 4.12.0
Angular: 5
It's in this file: src/main/webapp/app/shared/shared-libs.module.ts under the property "defaultI18nLang"

For jhipster 6.5.1 you should edit defaultI18nLang in /src/main/webapp/app/core/core.module.ts, for example defaultI18nLang: 'ar-ly'

And for JHipster 7.2.0 it's in src/main/webapp/app/app.module.ts under:
translateService.setDefaultLang('en');
// if user have changed language and navigates away from the application and back to the application then use previously choosed language;
const langKey = sessionStorageService.retrieve('locale') ?? 'en';

Related

AngularJS: Need language information in angularjs from language code

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'

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

Drupal paths not taking i18n / Multilingual-ness into account?

I have i18n on my Drupal website. If I am currently on the "spanish" version of the site, and I have this code:
drupal_get_path_alias("node/171");
It returns
about-us
I was expecting it to return:
es/about-us
How do I make drupal_get_path_alias aware of languages? Or must I include the prefix myself manually each time?
the language prefix has nothing to do with the path-alias. You could for instance not use path-prefix to determin language, but a cookie. Or maybe evne a sub-domain, or a different tld.
The language-prefix simply has nothing to do with the path-alias

How to programmatically add a language in drupal 7?

I'm in drupal 7 and I want to programmatically add a language except the default language when I'm writing a new profile. And set it to default.
I don't want to use translation:
http://localize.drupal.org/translate/downloads
Can anyone help?!
Thank you :)
With the Locale locale_add_language function. It is possible to create new languages. It also allows to set newly created language as default. In addition you can set default language by setting "language_default" variable to language object.
variable_set('language_default', $default);

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