-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from darrenlucas/load-translations
Allow loading translation messages from mo file for current locale
- Loading branch information
Showing
10 changed files
with
101 additions
and
11 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,12 @@ | ||
Test Locales | ||
============ | ||
|
||
This directory contains locales used for unit testing. | ||
|
||
To update locales from the pot file run the following: | ||
|
||
msgmerge --update fr/LC_MESSAGES/messages.po messages.pot | ||
|
||
To compile .mo files: | ||
|
||
msgfmt fr/LC_MESSAGES/messages.po -o fr/LC_MESSAGES/messages.mo |
Binary file not shown.
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,16 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: react-g 11n\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2017-01-15 20:51+0000\n" | ||
"PO-Revision-Date: 2017-01-27 14:35+0000\n" | ||
"Last-Translator: Darren Lucas <[email protected]>\n" | ||
"Language-Team: French\n" | ||
"Language: fr\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" | ||
|
||
msgid "hello" | ||
msgstr "bonjour" |
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 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Language: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=utf-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"POT-Creation-Date: 2017-01-15 20:51+0000\n" | ||
|
||
msgid "hello" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import translatorFactory from '../src/translator-factory'; | ||
|
||
const options = { | ||
localeDir: './test/fixtures/locale' | ||
} | ||
|
||
test('translatorFactory', () => { | ||
const translator = translatorFactory('fr', options); | ||
expect(translator.translate('hello')).toBe('bonjour'); | ||
}); | ||
|
||
test('translatorFactory with missing locale', () => { | ||
const translator = translatorFactory('es', options); | ||
expect(translator.translate('hello')).toBe('hello'); | ||
}); |