-
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.
- Loading branch information
Showing
5 changed files
with
73 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"effectiveMessage": "Message with effective content", | ||
"blankMessage": "Blank message", | ||
"messageWithPlaceholders": "Message with placeholders: ${one}, ${two}", | ||
"missingFallbackMessage": "Message defined in fallback locales", | ||
"missingMessage": "Message not defined in non-default locales" | ||
} |
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,7 @@ | ||
{ | ||
"effectiveMessage": "JP:意味ある内容を含むメッセージ", | ||
"blankMessage": "", | ||
"messageWithPlaceholders": "JP:プレースホルダーを含むメッセージ:${one}, ${two}, ${three}", | ||
"_missingFallbackMessage": "JP:フォールバック先で定義されているメッセージ", | ||
"_missingMessage": "JP:未定義のメッセージ" | ||
} |
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,7 @@ | ||
{ | ||
"effectiveMessage": "意味ある内容を含むメッセージ", | ||
"blankMessage": "空のメッセージ", | ||
"messageWithPlaceholders": "プレースホルダーを含むメッセージ:${one}, ${two}", | ||
"missingFallbackMessage": "フォールバック先で定義されているメッセージ", | ||
"_missingMessage": "未定義のメッセージ" | ||
} |
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,50 @@ | ||
/* | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
'use strict'; | ||
|
||
import "./l10n.mjs"; | ||
import { L10n } from "../../src/web/l10n.mjs"; | ||
import { assert } from "tiny-esm-test-runner"; | ||
const { is } = assert; | ||
|
||
let l10n; | ||
|
||
export async function setUp() { | ||
L10n.clearCache(); | ||
L10n.baseUrl = (new URL(`${import.meta.url}/../../fixtures/`)).toString(); | ||
l10n = new L10n("ja-JP"); | ||
await l10n.ready; | ||
} | ||
|
||
test_get.parameters = { | ||
effective: { | ||
key: "effectiveMessage", | ||
expected: "JP:意味ある内容を含むメッセージ", | ||
}, | ||
blank: { | ||
key: "blankMessage", | ||
expected: "", | ||
}, | ||
withPlaceholders: { | ||
key: "messageWithPlaceholders", | ||
params: { | ||
one: "One", | ||
two: "Two", | ||
}, | ||
expected: "JP:プレースホルダーを含むメッセージ:One, Two, ${three}", | ||
}, | ||
fallbackToGeneralLocale: { | ||
key: "missingFallbackMessage", | ||
expected: "フォールバック先で定義されているメッセージ", | ||
}, | ||
fallbackToDefaultLocale: { | ||
key: "missingMessage", | ||
expected: "Message not defined in non-default locales", | ||
}, | ||
}; | ||
export function test_get({ key, params, expected }) { | ||
is(expected, l10n.get(key, params || null)); | ||
} |