This repository has been archived by the owner on Aug 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add internationalization support (#738)
- Loading branch information
Showing
12 changed files
with
651 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { createFormatter, type Formatter } from '@vintl/compact-number' | ||
import { IntlController } from '@vintl/vintl/controller' | ||
|
||
const formatters = new WeakMap<IntlController<any>, Formatter>() | ||
|
||
export function useCompactNumber(): Formatter { | ||
const vintl = useVIntl() | ||
|
||
let formatter = formatters.get(vintl) | ||
|
||
if (formatter == null) { | ||
const formatterRef = computed(() => createFormatter(vintl.intl)) | ||
formatter = (value, options) => formatterRef.value(value, options) | ||
formatters.set(vintl, formatter) | ||
} | ||
|
||
return formatter | ||
} |
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 { createFormatter, type Formatter } from '@vintl/how-ago' | ||
import { IntlController } from '@vintl/vintl/controller' | ||
|
||
const formatters = new WeakMap<IntlController<any>, Formatter>() | ||
|
||
export function useRelativeTime(): Formatter { | ||
const vintl = useVIntl() | ||
|
||
let formatter = formatters.get(vintl) | ||
|
||
if (formatter == null) { | ||
const formatterRef = computed(() => createFormatter(vintl.intl)) | ||
formatter = (value, options) => formatterRef.value(value, options) | ||
formatters.set(vintl, formatter) | ||
} | ||
|
||
return formatter | ||
} |
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 @@ | ||
project_id: 518556 | ||
preserve_hierarchy: true | ||
|
||
files: | ||
- source: /locales/en-US/* | ||
dest: /%original_file_name% | ||
translation: /locales/%locale%/%original_file_name% |
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,17 @@ | ||
{ | ||
"frog": { | ||
"message": "You've been frogged! 🐸" | ||
}, | ||
"frog.altText": { | ||
"message": "A photorealistic painting of a frog labyrinth" | ||
}, | ||
"frog.froggedPeople": { | ||
"message": "{count, plural, one {{count} more person} other {{count} more people}} were also frogged!" | ||
}, | ||
"frog.sinceOpened": { | ||
"message": "This page was opened {ago}" | ||
}, | ||
"frog.title": { | ||
"message": "Frog" | ||
} | ||
} |
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,3 @@ | ||
{ | ||
"en-US": "American English" | ||
} |
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,6 @@ | ||
{ | ||
"displayName": { | ||
"description": "The name of the language in dialect form (e.g. Français canadien for French spoken in Canada, not French (Canada))", | ||
"message": "American English" | ||
} | ||
} |
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
Oops, something went wrong.