Hulk support multilingual feature which helps you to build your app in your native language. Read the documentation below carefully and follow the given steps.
How To Set Default Locale
Hulk provides you the options to change the default locale of the template according to your native language. You can change the locale in the AppConfig.js file. You can find the AppConfig.js file in the src->constants folder.
/**
App Config File
*/
const AppConfig = {
…,
// set default locale
locale: {
languageId: 'english', // language id
locale: 'en', // locale code
name: 'English', // locale name
icon: 'usa.png' // locale icon
}
}
export default AppConfig;
You can find the details about the other supported languages & their locales in the src->reducers->Appsettingsreducer.js file under the languages array. Just select the locale in which you want to convert your template and pass this value in the above file.
languages: [
// English
{
languageId: 'english',
locale: 'en',
name: 'English',
icon: 'en',
},
…
// Chinese
{
languageId: 'chinese',
locale: 'zh',
name: 'Chinese',
icon: 'chinese.png',
}
]
Hulk provides supports to 7 languages(built-in), They are: English, Chinese, French, Arabic, Spanish, Japanese and Korean.
How To Add A New Locale
Here are the instructions to add a new locale to your app. We have taken an example of adding the Greek language to the template.
Step 1: Create a file with the name of locale code inside the src->lang->locales directory and define the static strings which you want to translate into Greek, you can check the other locale files to check how strings are defined.
export default {
"sidebar.general": "γενικός",
"sidebar.horizontal": "οριζόντια"
}
Step 2: Create a file with the name of locale code inside the src->lang->entries directory and follow the same steps as in other files e.g.
import appLocaleData from 'react-intl/locale-data/el';
import elMessages from '../locales/el_EL';
const elLang = {
messages: {
…elMessages
},
locale: 'el-EL',
data: appLocaleData
};
export default elLang;
Step 3: Open index.js file under the src->lang directory and follow the steps given below in the code block.index.js
import appLocaleData from 'react-intl/locale-data/el';
import elMessages from '../locales/el_EL';
const elLang = {
messages: {
…elMessages
},
locale: 'el-EL',
data: appLocaleData
};
export default elLang;
Step 4: Now you need to add your locale inside the appsettingsreducer.js file under the src->reducers->Appsettingsreducer.js
/**
* App Settings Reducers
*/
...
const INIT_STATE = {
...,
languages: [
{
languageId: 'english',
locale: 'en',
name: 'English',
icon: 'usa.png',
},
...
// your new locale will goes here
{
languageId: 'greek',
locale: 'el',
name: 'Greek',
icon: 'greek.png',
}
]
}