Skip to content

feat: Portuguese translation #352

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

Merged
merged 4 commits into from
Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ module API. Options include:
container: '#some-query-selector'; // container to attach to
APIUrl: 'https://www.example.com/.netlify/functions/identity'; // Absolute url to endpoint. ONLY USE IN SPECIAL CASES!
namePlaceholder: 'some-placeholder-for-Name'; // custom placeholder for name input form
locale: 'en'; // language code for translations - available: en, fr, es - default to en
locale: 'en'; // language code for translations - available: en, fr, es, pt, hu - default to en
}
```

Expand Down
1 change: 1 addition & 0 deletions src/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@
<option value="fr">Fran&ccedil;ais</option>
<option value="es">Espa&ntilde;ol</option>
<option value="hu">Magyar</option>
<option value="pt">Portugu&ecirc;s</option>
</select>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/translations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import * as en from "./en.json";
import * as fr from "./fr.json";
import * as es from "./es.json";
import * as hu from "./hu.json";
import * as pt from "./pt.json";

export const defaultLocale = "en";
const translations = { en, fr, es, hu };
const translations = { en, fr, es, hu, pt };

export const getTranslation = (key, locale = defaultLocale) => {
const translated = translations[locale] && translations[locale][key];
Expand Down
7 changes: 7 additions & 0 deletions src/translations/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ describe("translations", () => {
expect(getTranslation("log_in", "es")).toEqual("Iniciar sesión");
});

it("should return translation for 'pt' locale", () => {
const { getTranslation } = require("./");
expect(getTranslation("log_in", "pt")).toEqual("Entrar");
});

it("should return key for non existing translation", () => {
const { getTranslation } = require("./");
expect(getTranslation("unknown_key")).toEqual("unknown_key");
Expand All @@ -38,11 +43,13 @@ describe("translations", () => {
jest.mock("./fr.json", () => ({}));
jest.mock("./hu.json", () => ({}));
jest.mock("./es.json", () => ({}));
jest.mock("./pt.json", () => ({}));

const { getTranslation } = require("./");
expect(getTranslation("log_in")).toEqual("Log in");
expect(getTranslation("log_in", "fr")).toEqual("Log in");
expect(getTranslation("log_in", "hu")).toEqual("Log in");
expect(getTranslation("log_in", "es")).toEqual("Log in");
expect(getTranslation("log_in", "pt")).toEqual("Log in");
});
});
41 changes: 41 additions & 0 deletions src/translations/pt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"log_in": "Entrar",
"log_out": "Sair",
"logged_in_as": "Logado como",
"logged_in": "Logado em",
"logging_in": "Logando em",
"logging_out": "Saindo",
"sign_up": "Registrar",
"signing_up": "Registrando",
"forgot_password": "Esqueceu a senha?",
"recover_password": "Recuperar senha",
"send_recovery_email": "Enviar email de recuperação de senha",
"sending_recovery_email": "Enviando email de recuperação de senha",
"never_mind": "Deixa pra lá",
"update_password": "Atualizar senha",
"updating_password": "Atualizando senha",
"complete_your_signup": "Complete seu registro",
"site_url_title": "Configurações de desenvolvimento",
"site_url_link_text": "Limpar URL do localhost",
"site_url_message": "Parece que você está executando um servidor local. Informe-nos o URL do seu site Netlify.",
"site_url_label": "Insira o URL do seu site Netlify",
"site_url_placeholder": "URL do seu site Netlify",
"site_url_submit": "Configure a URL do seu site",
"message_confirm": "Uma mensagem de confirmação foi enviada para o seu email, clique no link para continuar.",
"message_password_mail": "Enviamos um e-mail de recuperação para sua conta, siga o link para redefinir sua senha.",
"message_email_changed": "Seu email foi atualizado!",
"message_verfication_error": "Ocorreu um erro ao verificar sua conta. Tente novamente ou entre em contato com um administrador.",
"message_signup_disabled": "Registros públicos estão desabilitados. Contate um administrador e peça por um convite.",
"form_name_placeholder": "Nome",
"form_email_label": "Insira seu email",
"form_name_label": "Insira seu nome",
"form_email_placeholder": "Email",
"form_password_label": "Insira sua senha",
"form_password_placeholder": "Senha",
"coded_by": "Desenvolvido por Netlify",
"continue_with": "Continue com",
"No user found with this email": "Nenhum usuário encontrado com esse email",
"Invalid Password": "Senha inválida",
"Email not confirmed": "Email não confirmado",
"User not found": "Usuário não encontrado"
}