Adding a new i18n language

Since we enabled i18n support for our application, we can add new i18n languages easily at any time using the JHipster language generator. Let's add a new language to our application:

  1. In the Terminal, switch to a new branch and run the following command:
> git checkout -b add-tamil-language
> jhipster languages
  1. You will now see a prompt like the following, where you can choose any available language listed:
Using JHipster version installed locally in current project's node_modules
Executing jhipster:languages
Options:

Languages configuration is starting
? Please choose additional languages to install (Press <space> to select, <a> to toggle all, <i> to inverse selection)
>◯ Arabic (Libya)
◯ Armenian
◯ Catalan
◯ Chinese (Simplified)
◯ Chinese (Traditional)
◯ Czech
◯ Danish
(Move up and down to reveal more choices)
  1. Let's select Tamil here for now. Accept the proposed file changes and you are good to go. You will have to restart the npm start command. Once the application refreshes, you can see the new language in the language drop-down menu in the application menu. Now, wasn't that easy? Have a look at the following screenshot:

But there is a problem. Since we have some entities and we added a new language, we will need to get i18n Tamil files for entities as well. We can do this easily by running the jhipster --with-entities command, which will regenerate the application along with the entities. Make sure that you carefully stage only the changes that you need (i18n-related JSON files) from the diff and discard the remaining changes. The following are the files and folders that need to be staged:

.yo-rc.json
src/main/resources/i18n/messages_ta.properties
src/test/resources/i18n/messages_ta.properties
src/test/java/com/mycompany/store/service/MailServiceIT.java
src/main/webapp/app/shared/language/find-language-from-key.pipe.ts
src/main/webapp/app/shared/language/language.constants.ts
webpack/webpack.common.js
webpack/webpack.prod.js
src/main/webapp/i18n/ta/*

Now, let's commit this and merge it back to the master. If we have picked only i18n-related changes, then we shouldn't have any merge conflicts:

> git add --all
> git commit -am "add Tamil as additional language"
> git checkout master
> git merge --no-ff add-tamil-language

Now, let's see how to set up authorization for the application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset