-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make i18n consistently functional (#98)
* fix: make i18n consistently functional * chore: remove unused import from locales template
- Loading branch information
Showing
12 changed files
with
121 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: i18next-conv\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=utf-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1)\n" | ||
"POT-Creation-Date: 2019-05-20T12:03:17.005Z\n" | ||
"PO-Revision-Date: 2019-05-20T12:03:17.005Z\n" | ||
|
||
msgid "Hello {{name}}" | ||
msgstr "Hola {{name}}" | ||
|
||
msgid "Have a great {{dayOfTheWeek}}!" | ||
msgstr "Que tenga un buen {{dayOfTheWeek}}!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: i18next-conv\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=utf-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1)\n" | ||
"POT-Creation-Date: 2019-06-18T09:28:13.445Z\n" | ||
"PO-Revision-Date: 2019-06-18T09:28:13.445Z\n" | ||
|
||
msgid "Please sign in" | ||
msgstr "Por favor iniciar sesión" | ||
|
||
msgid "Server" | ||
msgstr "Servidor" | ||
|
||
msgid "Username" | ||
msgstr "Nombre de usuario" | ||
|
||
msgid "Password" | ||
msgstr "Contraseña" | ||
|
||
msgid "Sign in" | ||
msgstr "Iniciar sesión" | ||
|
||
msgid "An error occurred in the DHIS2 application." | ||
msgstr "" | ||
|
||
msgid "Something went wrong" | ||
msgstr "" | ||
|
||
msgid "Refresh to try again" | ||
msgstr "" | ||
|
||
msgid "Hide technical details" | ||
msgstr "" | ||
|
||
msgid "Show technical details" | ||
msgstr "" | ||
|
||
msgid "The following information may be requested by technical support." | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useEffect } from 'react' | ||
import i18n from '@dhis2/d2-i18n' | ||
import moment from 'moment' | ||
|
||
i18n.setDefaultNamespace('default') | ||
|
||
const simplifyLocale = locale => { | ||
const idx = locale.indexOf('-') | ||
if (idx === -1) { | ||
return locale | ||
} | ||
return locale.substr(0, idx) | ||
} | ||
|
||
const setGlobalLocale = locale => { | ||
if (locale !== 'en' && locale !== 'en-us') { | ||
import(`moment/locale/${locale}`).catch(() => { | ||
/* ignore */ | ||
}) | ||
} | ||
moment.locale(locale) | ||
|
||
const simplifiedLocale = simplifyLocale(locale) | ||
i18n.changeLanguage(simplifiedLocale) | ||
} | ||
|
||
export const useLocale = locale => { | ||
useEffect(() => { | ||
setGlobalLocale(locale || window.navigator.language) | ||
}, [locale]) | ||
} |
This file was deleted.
Oops, something went wrong.