<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alex Cibotari</title>
    <description>The latest articles on DEV Community by Alex Cibotari (@alexcibotari).</description>
    <link>https://dev.to/alexcibotari</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1247543%2Fc8da5173-0369-4524-bfff-6dbb64a1e037.jpeg</url>
      <title>DEV Community: Alex Cibotari</title>
      <link>https://dev.to/alexcibotari</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alexcibotari"/>
    <language>en</language>
    <item>
      <title>Revolutionizing Translation Management: Lessify Tools for Efficient JSON File Merging</title>
      <dc:creator>Alex Cibotari</dc:creator>
      <pubDate>Thu, 04 Jan 2024 08:48:28 +0000</pubDate>
      <link>https://dev.to/alexcibotari/revolutionizing-translation-management-lessify-tools-for-efficient-json-file-merging-2an9</link>
      <guid>https://dev.to/alexcibotari/revolutionizing-translation-management-lessify-tools-for-efficient-json-file-merging-2an9</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In single-page applications like Angular, we use &lt;strong&gt;@ngx-translate/core&lt;/strong&gt; or &lt;strong&gt;@ngneat/transloco&lt;/strong&gt;. Managing all translations in one file will be challenging and unmaintainable in the long term. There is a solution to solve it if you store all your internationalization keys in the project.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Translation Dilemma
&lt;/h2&gt;

&lt;p&gt;I will compare translations with CSS, in a project you have two types of CSS or Translations :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Global Level - the one used across whole applications and is reusable, like "&lt;strong&gt;OK&lt;/strong&gt;", "&lt;strong&gt;Cancel&lt;/strong&gt;", "&lt;strong&gt;Back&lt;/strong&gt;", and others.&lt;/li&gt;
&lt;li&gt;Component Level - Specific to that component only translations, for example for the Login Page Component it will be: "&lt;strong&gt;Login&lt;/strong&gt;", "&lt;strong&gt;Sing-Up&lt;/strong&gt;", "&lt;strong&gt;Combination of user and password is wrong&lt;/strong&gt;", and others&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keeping them in one file will create problems, as it will grow without control of your application and will slow down the initial payload. Same time when you delete a component, you will need to search for all used translations in a huge file per language.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessify Angular Tools
&lt;/h2&gt;

&lt;p&gt;What if you can have those Translations at the same level as you use them at the component or the module level?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;├─ login ( merge them in one sub-folder )
   ├─ login.component.ts
   ├─ login.component.scss
   ├─ login.component.html
   ├─ i18n //login component only translations
      ├─ en.json
      ├─ de.json
├─ login ( keep them in the same folder )
   ├─ login.component.ts
   ├─ login.component.scss
   ├─ login.component.html
   ├─ en.json
   ├─ de.json
├─ shared
   ├─ i18n //global translations
      ├─ en.json
      ├─ de.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this way, they are a natural part of your application.&lt;/p&gt;

&lt;p&gt;With &lt;a href="https://www.npmjs.com/package/@lessify/angular-tools"&gt;Angular Lessify Tools&lt;/a&gt; you can merge them in one at build time :&lt;/p&gt;

&lt;p&gt;Install :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;-D&lt;/span&gt; @lessify/angular-tools
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Configuration &lt;code&gt;lessify.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"cwd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./src/app"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"output"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./src/assets/i18n"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"languages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"en"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"de"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"fr"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"it"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For more details, you can find the &lt;a href="https://www.npmjs.com/package/@lessify/angular-tools"&gt;official documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add to your build commands in &lt;code&gt;package.json&lt;/code&gt; :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;scripts:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"prebuild:build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ng g @lessify/angular-tools:i18n-merge"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"i18n-check"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ng g @lessify/angular-tools:i18n-check"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"i18n-merge"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ng g @lessify/angular-tools:i18n-merge"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Future Innovations
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://www.npmjs.com/package/@lessify/angular-tools"&gt;Angular Lessify Tools&lt;/a&gt; is &lt;strong&gt;Open Source&lt;/strong&gt; and &lt;strong&gt;Free to use&lt;/strong&gt;. Waiting for your feedback and improvements.&lt;/p&gt;

&lt;p&gt;In case you like it, feel free to send a star and support our project &lt;a href="https://github.com/Lessify/lessify-angular"&gt;Angular Lessify Tools on GitHub&lt;/a&gt; and &lt;a href="https://github.com/sponsors/Lessify"&gt;Become a sponsor&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus
&lt;/h2&gt;

&lt;p&gt;I'm also working on an application &lt;a href="https://github.com/Lessify/localess"&gt;&lt;strong&gt;Localess&lt;/strong&gt;&lt;/a&gt; that helps to store translations for your single-page applications in one place. The &lt;a href="https://github.com/Lessify/localess"&gt;&lt;strong&gt;Localess&lt;/strong&gt;&lt;/a&gt; is &lt;strong&gt;Open Source&lt;/strong&gt; and &lt;strong&gt;Free to use&lt;/strong&gt; and can be deployed and hosted on &lt;strong&gt;Firebase&lt;/strong&gt;. In case you like it, give us a star to motivate us. Waiting for your feedback.&lt;/p&gt;

&lt;p&gt;Thank you !!!!!&lt;/p&gt;

</description>
      <category>angular</category>
      <category>i18n</category>
      <category>firebase</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
