|
3 | 3 |
|
4 | 4 | import { assertNotEquals, assertStrictEquals } from 'https://deno.land/std/testing/asserts.ts'
|
5 | 5 | import { basename, dirname, extname, posix } from 'https://deno.land/std/path/mod.ts'
|
6 |
| -import { sprintf } from 'https://deno.land/std/fmt/printf.ts' |
7 | 6 |
|
8 | 7 | import cliui from 'https://deno.land/x/cliui@v7.0.0-deno/deno.ts'
|
9 | 8 | import escalade from 'https://deno.land/x/escalade@v3.0.3/sync.ts'
|
10 | 9 | import Parser from 'https://deno.land/x/yargs_parser@v19.0.1-deno/deno.ts'
|
| 10 | +import y18n from 'https://deno.land/x/y18n@v5.0.0-deno/deno.ts' |
11 | 11 | import { YError } from '../../build/lib/yerror.js'
|
12 | 12 |
|
13 | 13 | const REQUIRE_ERROR = 'require is not supported by ESM'
|
14 | 14 | const REQUIRE_DIRECTORY_ERROR = 'loading a directory of commands is not supported yet for ESM'
|
15 | 15 |
|
16 | 16 | // Deno removes argv[0] and argv[1 from Deno.args:
|
17 | 17 | const argv = ['deno run', ...Deno.args]
|
| 18 | +const __dirname = new URL('.', import.meta.url).pathname |
18 | 19 |
|
19 | 20 | // Yargs supports environment variables with prefixes, e.g., MY_APP_FOO,
|
20 | 21 | // MY_APP_BAR. Environment variables are also used to detect locale.
|
21 | 22 | let cwd: string = ''
|
22 | 23 | let env: {[key: string]: string} = {}
|
23 | 24 | try {
|
24 |
| - cwd = Deno.cwd() |
25 | 25 | env = Deno.env.toObject()
|
| 26 | + cwd = Deno.cwd() |
26 | 27 | } catch (err) {
|
27 | 28 | if (err.name !== 'PermissionDenied') {
|
28 | 29 | throw err
|
@@ -94,23 +95,8 @@ export default {
|
94 | 95 | stringWidth: (str: string) => {
|
95 | 96 | return [...str].length
|
96 | 97 | },
|
97 |
| - y18n: { |
98 |
| - __: (...str: string[]) => { |
99 |
| - if (str.length === 0) return '' |
100 |
| - const args = str.slice(1) |
101 |
| - return sprintf(str[0], ...args) |
102 |
| - }, |
103 |
| - __n: (str1: string, str2: string, count: number, ...args: string[]) => { |
104 |
| - if (count === 1) { |
105 |
| - return sprintf(str1, ...args) |
106 |
| - } else { |
107 |
| - return sprintf(str2, ...args) |
108 |
| - } |
109 |
| - }, |
110 |
| - getLocale: (): string => { |
111 |
| - return 'en_US' |
112 |
| - }, |
113 |
| - setLocale: () => {}, |
114 |
| - updateLocale: () => {} |
115 |
| - } |
| 98 | + y18n: y18n({ |
| 99 | + directory: posix.resolve(__dirname, '../../locales'), |
| 100 | + updateFiles: false |
| 101 | + }) |
116 | 102 | }
|
0 commit comments