<?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: NEIWAD</title>
    <description>The latest articles on DEV Community by NEIWAD (@neiwad).</description>
    <link>https://dev.to/neiwad</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%2F974420%2F210e7751-a363-4408-b63c-57d703cad511.png</url>
      <title>DEV Community: NEIWAD</title>
      <link>https://dev.to/neiwad</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/neiwad"/>
    <language>en</language>
    <item>
      <title>Svelte + Tailwind + Firebase Auth</title>
      <dc:creator>NEIWAD</dc:creator>
      <pubDate>Sun, 27 Nov 2022 18:48:39 +0000</pubDate>
      <link>https://dev.to/neiwad/svelte-tailwind-firebase-auth-4haa</link>
      <guid>https://dev.to/neiwad/svelte-tailwind-firebase-auth-4haa</guid>
      <description>&lt;h2&gt;
  
  
  👋 Hi guys!
&lt;/h2&gt;

&lt;p&gt;I just released a Svelte, Firebase and Tailwind starter.&lt;/p&gt;

&lt;p&gt;This is a great way to learn Svelte routing and Firebase authentication. &lt;/p&gt;

&lt;p&gt;Not perfect but I will improve it soon 🔥 &lt;/p&gt;

&lt;p&gt;Feel free to create PR or issues if needed!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://svelte-tailwind-firebase.vercel.app"&gt;Example&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/neiwad/svelte-tailwind-firebase"&gt;Repository&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>svelte</category>
      <category>firebase</category>
      <category>tailwindcss</category>
    </item>
    <item>
      <title>Vue3 + i18n (bonus i18n ally)</title>
      <dc:creator>NEIWAD</dc:creator>
      <pubDate>Thu, 17 Nov 2022 18:52:52 +0000</pubDate>
      <link>https://dev.to/neiwad/vue3-i18n-bonus-i18n-ally-5d1p</link>
      <guid>https://dev.to/neiwad/vue3-i18n-bonus-i18n-ally-5d1p</guid>
      <description>&lt;p&gt;How to configure i18n and vue3 so that at the end of the project the translation files are not 10000 lines long and incomprehensible.&lt;/p&gt;

&lt;p&gt;The solution? i18n namespaced files and the i18n ally extension!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Create a brand new project
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm create vue@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✔ Project name: … vue3-i18n
✔ Add TypeScript? … Yes
✔ Add JSX Support? … No
✔ Add Vue Router for Single Page Application development? … No
✔ Add Pinia for state management? … No
✔ Add Vitest for Unit Testing? … No
✔ Add an End-to-End Testing Solution? › No
✔ Add ESLint for code quality? … No
✔ Add Prettier for code formatting? … No
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm install &amp;amp;&amp;amp; pnpm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should now bet able to see a basic Vue3 project on &lt;strong&gt;localhost:5173&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. i18n
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Install i18n for Vue3
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm install vue-i18n@9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create some translation files
&lt;/h3&gt;

&lt;p&gt;Here is my architecture. Follow it for this tutorial, you can change it later with some job.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ciclisu4k3nz2j4c5ln.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ciclisu4k3nz2j4c5ln.png" alt="i18n files architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;locales/en/auth.json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "SignIn": "Sign In",
  "SignUp": "Sign Up"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;locales/en/commons.json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "height": "Height",
  "weight": "Weight"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the FR part, I let you translate by yourself!&lt;/p&gt;

&lt;h3&gt;
  
  
  Init i18n configuration file
&lt;/h3&gt;

&lt;p&gt;Inside locales folder create an &lt;strong&gt;index.ts&lt;/strong&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { createI18n, type I18n, type Locale } from "vue-i18n";
import authEN from "./en/auth.json";
import authFR from "./fr/auth.json";
import commonsEN from "./en/commons.json";
import commonsFR from "./fr/commons.json";

let i18n: I18n;

const init = () =&amp;gt; {
  i18n = createI18n({
    locale: "en",
    messages: {
      en: {
        auth: authEN,
        commons: commonsEN,
      },
      fr: {
        auth: authFR,
        commons: commonsFR,
      },
    },
  });
};

const setLocale = (locale: Locale): void =&amp;gt; {
  i18n.global.locale = locale;
};

init();

export { i18n, setLocale };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Add i18n to the Vue3 app
&lt;/h3&gt;

&lt;p&gt;inside the &lt;strong&gt;main.ts&lt;/strong&gt; import i18n as&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { i18n } from "./locales";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the use this i18n&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;createApp(App).use(i18n).mount("#app");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Test our integration
&lt;/h2&gt;

&lt;p&gt;Replace the content of App.vue with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script setup lang="ts"&amp;gt;
  import {setLocale} from "./locales"
  const changeLocale = () =&amp;gt; {
    setLocale('fr')
  }
&amp;lt;/script&amp;gt;

&amp;lt;template&amp;gt;
  &amp;lt;main&amp;gt;
    {{$t('auth.SignIn')}}
    {{$t('commons.height')}}
    &amp;lt;button @click=changeLocale&amp;gt;Change Locale&amp;lt;/button&amp;gt;
  &amp;lt;/main&amp;gt;
&amp;lt;/template&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5b3nf0sfae0g32x2c9sj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5b3nf0sfae0g32x2c9sj.png" alt="integration testing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And if you click on the button... TADA! Strings are no FR ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Bonus: i18n ally
&lt;/h2&gt;

&lt;p&gt;Dealing with a large set of locales and translation can be such a pain in the a$$. &lt;/p&gt;

&lt;p&gt;This is where the &lt;a href="https://marketplace.visualstudio.com/items?itemName=Lokalise.i18n-ally" rel="noopener noreferrer"&gt;i18n ally extension&lt;/a&gt; come to the rescue.&lt;/p&gt;

&lt;h3&gt;
  
  
  i18n ally installation
&lt;/h3&gt;

&lt;p&gt;You can add it to VSCode from the embeded marketplace or from &lt;a href="https://marketplace.visualstudio.com/items?itemName=Lokalise.i18n-ally" rel="noopener noreferrer"&gt;this link&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  i18n ally configuration
&lt;/h3&gt;

&lt;p&gt;Open &lt;strong&gt;User Settings Preferences (JSON)&lt;/strong&gt; from the quick access shortcut.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;shift + cmd + p
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the add in the end of the JSON file these lines&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  "i18n-ally.dirStructure": "auto",
  "i18n-ally.enabledFrameworks": ["vue"],
  "i18n-ally.enabledParsers": ["json", "yaml"],
  "i18n-ally.extract.autoDetect": true,
  "i18n-ally.namespace": true,
  "i18n-ally.pathMatcher": "{locale}/{namespaces}.json",
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  i18n ally usage
&lt;/h3&gt;

&lt;p&gt;When i18n ally is installed and configured in VSCode, you can open it from the sidebar button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7v6lvyt7f00wgq1csspe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7v6lvyt7f00wgq1csspe.png" alt="i18n ally"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I let you play with this useful extension, but with it you can auto translate your string, create keys and see you translation coverage. &lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://vuejs.org/guide/introduction.html" rel="noopener noreferrer"&gt;vue3&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/intlify/vue-i18n-next" rel="noopener noreferrer"&gt;vue-i18n-next&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7v6lvyt7f00wgq1csspe.png" rel="noopener noreferrer"&gt;i18n-ally&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Questions?
&lt;/h2&gt;

&lt;p&gt;If you have some questions or issues, please share it with me in a comment, I will take a look at it quickly :) &lt;/p&gt;

&lt;p&gt;Ciao &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>vue</category>
      <category>i18n</category>
      <category>vite</category>
    </item>
  </channel>
</rss>
