-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Call getMatchableLocales in importMessages
- Loading branch information
1 parent
58fbaa3
commit 1dac34a
Showing
4 changed files
with
39 additions
and
25 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 |
---|---|---|
@@ -1,4 +1,9 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// It's fine for importMessages to raise TypeScript requirements because | ||
// it will usually be accompanied by the I18nProvider anyway. | ||
// eslint-disable-next-line @cloudscape-design/ban-files | ||
import { I18nProviderProps } from './provider'; | ||
|
||
export function importMessages(locale: string): Promise<ReadonlyArray<I18nProviderProps.Messages>>; |
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 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export function getMatchableLocales(ietfLanguageTag: string): string[] { | ||
const parts = ietfLanguageTag.split('-'); | ||
if (parts.length === 1) { | ||
return [ietfLanguageTag]; | ||
} | ||
|
||
const localeStrings: string[] = []; | ||
for (let i = parts.length; i > 0; i--) { | ||
localeStrings.push(parts.slice(0, i).join('-')); | ||
} | ||
return localeStrings; | ||
} |
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