-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for internationalization
Make the whole thing multilingual by using FormatJS. Currently only has English and Finnish translations.
- Loading branch information
Showing
17 changed files
with
339 additions
and
110 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
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
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,14 @@ | ||
{ | ||
"add": "Add", | ||
"addNewEntry": "Add new entry", | ||
"apiError": "API returned erroneous response.", | ||
"cancel": "Cancel", | ||
"deleteAll": "Delete all", | ||
"deleteAllConfirmation": "Do you really want to delete all entries marked as done?", | ||
"editEntry": "Edit entry", | ||
"no": "No", | ||
"text": "Text", | ||
"url": "URL", | ||
"unableToSaveChanges": "Unable to save changes.", | ||
"yes": "Yes" | ||
} |
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,14 @@ | ||
{ | ||
"add": "Lisää", | ||
"addNewEntry": "Lisää uusi kohta", | ||
"apiError": "Palvelin palautti virheen.", | ||
"cancel": "Peruuta", | ||
"deleteAll": "Poista kaikki", | ||
"deleteAllConfirmation": "Haluatko varmasti poistaa kaikki valmiiksi merkityt kohteet?", | ||
"editEntry": "Muokkaa", | ||
"no": "Ei", | ||
"text": "Teksti", | ||
"url": "Verkko-osoite", | ||
"unableToSaveChanges": "Tallentaminen epäonnistui.", | ||
"yes": "Kyllä" | ||
} |
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,18 @@ | ||
import enTranslations from './en.json'; | ||
import fiTranslations from './fi.json'; | ||
|
||
const SUPPORTED_LANGUAGES = new Set<string>(['en', 'fi']); | ||
const DEFAULT_LANGUAGE = 'en'; | ||
|
||
export const translations: Record<string, Record<string, string>> = { | ||
en: enTranslations, | ||
fi: fiTranslations, | ||
}; | ||
|
||
export const getBrowserLanguage = (): string => { | ||
const browserLanguageCode = navigator.language.split(/[-_]/)[0]; | ||
|
||
return SUPPORTED_LANGUAGES.has(browserLanguageCode) | ||
? browserLanguageCode | ||
: DEFAULT_LANGUAGE; | ||
}; |
Oops, something went wrong.