{"id":36,"date":"2019-10-07T09:54:38","date_gmt":"2019-10-07T09:54:38","guid":{"rendered":"https:\/\/docs.theironnetwork.org\/embryo\/?page_id=36"},"modified":"2019-10-15T09:35:25","modified_gmt":"2019-10-15T09:35:25","slug":"translate-app","status":"publish","type":"page","link":"https:\/\/docs.theironnetwork.org\/embryo\/translate-app\/","title":{"rendered":"Translate App"},"content":{"rendered":"\n<p><em><strong>Embryo-Angular<\/strong><\/em> support multilingual feature which helps you to build your app in your native language. Read the documentation carefully and follow the steps. Embryo by default supports 2 languages, they are: <strong>English <\/strong>and <strong>French<\/strong>.\u200c<\/p>\n\n\n\n<h5 id=\"how-to-set-default-locale\"><strong>How To Set Default Locale<\/strong><\/h5>\n\n\n\n<p>If you want to change your default locale(you can select any of the given locale as default for your template) then you can follow the steps given below:\u200c<\/p>\n\n\n\n<p><strong>Step 1:<\/strong> Go to the <code>src-&gt;app<\/code> folder and open <code>app.component.ts<\/code> file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import { TranslateService } from '@ngx-translate\/core';<br> <br>export class AppComponent {<br>   constructor(translate: TranslateService) {<br>      translate.setDefaultLang('en');<br>   }<br>}<\/pre>\n\n\n\n<p><strong>Step 2: <\/strong>Now change the language code to your desired language code. You can get the language code from the table above.\u200c<\/p>\n\n\n\n<h5 id=\"how-to-add-a-new-locale\">How To Add A New Locale<\/h5>\n\n\n\n<p>Here are the instructions to add a new locale in your app. We are taking an example of <strong>French<\/strong> that we are going to add.\u200c<\/p>\n\n\n\n<p><strong>Step 1: <\/strong>Create a <code>json<\/code> file with name of locale code inside the <code>src-&gt;assets-&gt;i18n<\/code> folder.\u200c<\/p>\n\n\n\n<p><strong>Step 2:<\/strong> Open the <code>fr.json<\/code> file that you have just created and define the static strings which you want to translate into French, you can check the other locale files to check how strings are defined.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{<br>  \"HOME\":\"Accueil\",<br>  \"SHOP\":\"Boutique\",<br>  \"PRODUCT DETAILS\": \"d\u00e9tails du produit\",<br>  \"CART\" : \"Chariot\"<br>}<\/pre>\n\n\n\n<p><strong>Step 3:<\/strong> Now you need to add your locale inside the <code>app.component.ts<\/code> file under the <code>src-&gt;app<\/code> folder.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import { TranslateService } from '@ngx-translate\/core';<br> <br>export class AppComponent {<br>   constructor(translate: TranslateService) {<br>      translate.addLangs(['en', 'fr']);<br>      <br>      const browserLang: string = translate.getBrowserLang();<br>      translate.use(browserLang.match(\/en|fr\/) ? browserLang : 'en');<br>   }<br>}<br>\u200c<br><\/pre>\n\n\n\n<p>Now , where you want to use the translation language then you can use it as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;a class=\"nav-link\" routerLinkActive=\"active-link\"&gt;<br>   {{item.name | translate}}<br> &lt;\/a&gt;<\/pre>\n\n\n\n<p>That&#8217;s it, Now you can translate your app in your preferred language.<\/p>\n<div class=\"pld-like-dislike-wrap pld-template-1\">\n    <div class=\"pld-like-wrap  pld-common-wrap\">\n    <a href=\"javascript:void(0);\" class=\"pld-like-trigger pld-like-dislike-trigger \" title=\"\" data-post-id=\"36\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-ip-check=\"0\" data-user-check=\"1\">\n                        <i class=\"fas fa-thumbs-up\"><\/i>\n                    <\/a>\n    <span class=\"pld-like-count-wrap pld-count-wrap\">    <\/span>\n<\/div><div class=\"pld-dislike-wrap  pld-common-wrap\">\n    <a href=\"javascript:void(0);\" class=\"pld-dislike-trigger pld-like-dislike-trigger \" title=\"\" data-post-id=\"36\" data-trigger-type=\"dislike\" data-ip-check=\"0\" data-restriction=\"cookie\" data-user-check=\"1\">\n                        <i class=\"fas fa-thumbs-down\"><\/i>\n                    <\/a>\n    <span class=\"pld-dislike-count-wrap pld-count-wrap\"><\/span>\n<\/div><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>Embryo-Angular support multilingual feature which helps you to build your app in your native language. Read the documentation carefully and follow the steps. Embryo by default supports 2 languages, they are: English and French.\u200c How To Set Default Locale If you want to change your default locale(you can select any of the given locale as [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":5,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/pages\/36"}],"collection":[{"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/comments?post=36"}],"version-history":[{"count":7,"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/pages\/36\/revisions"}],"predecessor-version":[{"id":287,"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/pages\/36\/revisions\/287"}],"wp:attachment":[{"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/media?parent=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}