{"id":82,"date":"2019-10-07T11:02:13","date_gmt":"2019-10-07T11:02:13","guid":{"rendered":"https:\/\/docs.theironnetwork.org\/embryo\/?page_id=82"},"modified":"2019-10-15T09:44:15","modified_gmt":"2019-10-15T09:44:15","slug":"translate-the-app","status":"publish","type":"page","link":"https:\/\/docs.theironnetwork.org\/embryo\/translate-the-app\/","title":{"rendered":"Translate The App"},"content":{"rendered":"\n<p><em><strong>Embryo-ReactJS<\/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 then you can change it in the <code>AppConfig.js<\/code> file. You can find the <code>AppConfig.js<\/code> file in the <code>src-&gt;constants<\/code> folder.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/**<br>* App Config File<br>*\/<br>const AppConfig = {<br>    ...,<br>    \/\/ set default locale <br>    locale: {<br>        locale: 'en',          \/\/ locale code<br>        name: 'English',       \/\/ locale name<br>        icon: 'en'             \/\/ locale icon<br>    }<br>}<br>export default AppConfig;  <\/pre>\n\n\n\n<p>The template by default supports two locales i.e. <strong>English<\/strong> &amp; <strong>French<\/strong>. You can check the languages in <code>src-&gt;assets-&gt;data-&gt;localeData.js<\/code> file. Copy the locale in which you want to convert your template and paste the locale in the <code>AppConfig.js<\/code> file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/**<br> * locales data<br> *\/<br>export const languages = [<br>    {<br>        locale: 'en',<br>        name: 'English',<br>        icon: 'en',<br>    },<br>    {<br>        locale: 'fr',<br>        name: 'French',<br>        icon: 'fr',<br>    }<br>]<\/pre>\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>Greek<\/strong> that we are going to add.\u200c<\/p>\n\n\n\n<p><strong>Step 1:<\/strong> Create a file with the name of locale code inside the <code>src-&gt;lang-&gt;locales<\/code> directory and define the static strings which you want to translate into <strong>Greek<\/strong>, you can check the other locale files to check how strings are defined.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">module.exports = {<br>   \"menu.Home\": \"\u03a3\u03c0\u03af\u03c4\u03b9\",<br>   \"menu.HomeOne\": \"\u03ba\u03b1\u03c4\u03ac\u03c3\u03c4\u03b7\u03bc\u03b1\",<br>   ...<br>}<\/pre>\n\n\n\n<p><strong>Step 2:<\/strong> Create a file with the name of locale code inside the <code>src-&gt;lang-&gt;entries<\/code> directory and follow the same steps as in other files e.g.,<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import appLocaleData from 'react-intl\/locale-data\/el';<br>import elMessages from '..\/locales\/el_EL';<br> <br>const elLang = {<br>    messages: {<br>        ...elMessages<br>    },<br>    locale: 'el-EL',<br>    data: appLocaleData<br>};<br>export default elLang;<br>\u200c<br><\/pre>\n\n\n\n<p>\u200c<strong>Step 3:<\/strong> Open <code>index.js<\/code> file under the <code>src-&gt;lang<\/code> directory and follow the steps given below in the code block.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import { addLocaleData } from 'react-intl';<br>import enLang from '.\/entries\/en-US';<br>...<br>import elLang from '.\/entries\/el_EL'; \/\/ Import the locale here<br> <br>const AppLocale = {<br>    ...,<br>    el: elLang<br>};<br> <br>...<br>addLocaleData(AppLocale.el.data);<br> <br>export default AppLocale;<br> <\/pre>\n\n\n\n<p><strong>Step 4:<\/strong> Now you need to add your locale inside the  <code>localeData.js<\/code> file under the <code>src-&gt;assets-&gt;data<\/code> directory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/**<br> * locales data<br> *\/<br>export const languages = [<br>    {<br>        locale: 'en',<br>        name: 'English',<br>        icon: 'en',<br>    },<br>    {<br>        locale: 'fr',<br>        name: 'French',<br>        icon: 'fr',<br>    },<br>    {<br>        locale: 'el',<br>        name: 'Greek',<br>        icon: 'el',<br>    }<br>]<\/pre>\n\n\n\n<p>That&#8217;s it, Now you are done with adding a new locale to the template. If you want this newly added locale as your default then you can follow the steps given in the above section <strong>How To Set Default Locale<\/strong> to set it as your default locale.<\/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=\"82\" 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\">1    <\/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=\"82\" 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-ReactJS 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 then you can change it in the AppConfig.js [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":14,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/pages\/82"}],"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=82"}],"version-history":[{"count":8,"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/pages\/82\/revisions"}],"predecessor-version":[{"id":292,"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/pages\/82\/revisions\/292"}],"wp:attachment":[{"href":"https:\/\/docs.theironnetwork.org\/embryo\/wp-json\/wp\/v2\/media?parent=82"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}