Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add i18n support with gitauto model #234

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8eadcab
Update package.json
gitauto-ai[bot] Jul 9, 2024
6b6b9ed
Update src/index.js
gitauto-ai[bot] Jul 9, 2024
b6a1a11
Update src/i18n.js
gitauto-ai[bot] Jul 9, 2024
a6b6aeb
Update src/locales/en/translation.json
gitauto-ai[bot] Jul 9, 2024
85750ef
Update src/locales/es/translation.json
gitauto-ai[bot] Jul 9, 2024
db3224c
Update src/Components/LanguageSwitcher.js
gitauto-ai[bot] Jul 9, 2024
da31b20
Update src/App.js
gitauto-ai[bot] Jul 9, 2024
594206e
Merge branch 'main' into gitauto/issue-#67-4413c6ab-ca11-4e0e-897b-99…
guibranco Jul 15, 2024
4f48b66
Update LanguageSwitcher.js
guibranco Jul 16, 2024
41ba7e2
Update i18n.js
guibranco Jul 16, 2024
4f5ef83
Create translation.json
guibranco Jul 16, 2024
54b55d6
Update translation.json
guibranco Jul 16, 2024
c696a99
Update translation.json
guibranco Jul 16, 2024
eb5ee90
Update translation.json
guibranco Jul 16, 2024
9f71793
Update i18n.js
guibranco Jul 16, 2024
a9c05db
Merge branch 'main' into gitauto/issue-#67-4413c6ab-ca11-4e0e-897b-99…
guibranco Aug 19, 2024
d12e326
Merge branch 'main' into gitauto/issue-#67-4413c6ab-ca11-4e0e-897b-99…
gstraccini[bot] Aug 25, 2024
a025390
Merge branch 'main' into gitauto/issue-#67-4413c6ab-ca11-4e0e-897b-99…
gstraccini[bot] Aug 26, 2024
332cd4b
Merge branch 'main' into gitauto/issue-#67-4413c6ab-ca11-4e0e-897b-99…
gstraccini[bot] Aug 30, 2024
d892f62
Merge branch 'main' into gitauto/issue-#67-4413c6ab-ca11-4e0e-897b-99…
gstraccini[bot] Aug 30, 2024
2971f1a
Merge branch 'main' into gitauto/issue-#67-4413c6ab-ca11-4e0e-897b-99…
gstraccini[bot] Aug 31, 2024
99f9671
Merge branch 'main' into gitauto/issue-#67-4413c6ab-ca11-4e0e-897b-99…
gstraccini[bot] Sep 1, 2024
2aa30c6
Merge branch 'main' into gitauto/issue-#67-4413c6ab-ca11-4e0e-897b-99…
gstraccini[bot] Sep 1, 2024
f7d661e
Merge branch 'main' into gitauto/issue-#67-4413c6ab-ca11-4e0e-897b-99…
gstraccini[bot] Sep 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Components/LanguageSwitcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from "react";
import { useTranslation } from "react-i18next";

const LanguageSwitcher = () => {
const { i18n } = useTranslation();
const changeLanguage = (lng) => {
i18n.changeLanguage(lng);
};

return (
<div>
<button onClick={() => changeLanguage("pt")}>Português</button>

Check notice on line 12 in src/Components/LanguageSwitcher.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Components/LanguageSwitcher.js#L12

disallow literal string: <button onClick={() => changeLanguage("pt")}>Português</button>
<button onClick={() => changeLanguage("en")}>English</button>

Check notice on line 13 in src/Components/LanguageSwitcher.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Components/LanguageSwitcher.js#L13

disallow literal string: <button onClick={() => changeLanguage("en")}>English</button>
<button onClick={() => changeLanguage("es")}>Español</button>

Check notice on line 14 in src/Components/LanguageSwitcher.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Components/LanguageSwitcher.js#L14

disallow literal string: <button onClick={() => changeLanguage("es")}>Español</button>
</div>
);
}

Check notice on line 17 in src/Components/LanguageSwitcher.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Components/LanguageSwitcher.js#L17

Insert `;`
export default LanguageSwitcher;
20 changes: 20 additions & 0 deletions src/i18n.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import ptTranslation from "./locales/pt/translation.json";
import enTranslation from "./locales/en/translation.json";
import esTranslation from "./locales/es/translation.json";

const resources = {
pt: {
translation: ptTranslation,
},
en: {
translation: enTranslation,
},
es: {
translation: esTranslation,
},
};

i18n.use(initReactI18next).init({ resources, lng: "pt", fallbackLng: "en", interpolation: { escapeValue: false } });

Check notice on line 19 in src/i18n.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/i18n.js#L19

Replace `.use(initReactI18next).init({·resources,·lng:·"pt",·fallbackLng:·"en",·interpolation:·{·escapeValue:·false·}` with `⏎··.use(initReactI18next)⏎··.init({⏎····resources,⏎····lng:·"pt",⏎····fallbackLng:·"en",⏎····interpolation:·{·escapeValue:·false·},⏎·`
export default i18n;
4 changes: 4 additions & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"welcome": "Welcome",
"language": "Language"
}
4 changes: 4 additions & 0 deletions src/locales/es/translation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"welcome": "Bienvenido",
"language": "Idioma"
}
4 changes: 4 additions & 0 deletions src/locales/pt/translation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"welcome": "Bem vindo",
"language": "Idioma"
}