mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Create own directory for i18n
This commit is contained in:
parent
402b56e5b1
commit
4083f16848
12 changed files with 47 additions and 36 deletions
|
@ -1,5 +1,5 @@
|
|||
licenses.json
|
||||
vendor
|
||||
i18n-translate.ts
|
||||
i18n-modules.ts
|
||||
lib/i18n/translate.ts
|
||||
lib/i18n/modules.ts
|
||||
backend_proto.d.ts
|
||||
|
|
|
@ -1,26 +1,11 @@
|
|||
load("@rules_python//python:defs.bzl", "py_binary")
|
||||
load("//ts:prettier.bzl", "prettier_test")
|
||||
load("//ts:eslint.bzl", "eslint_test")
|
||||
load("//ts:protobuf.bzl", "protobufjs_library")
|
||||
load("//ts:typescript.bzl", "typescript")
|
||||
load("@rules_python//python:defs.bzl", "py_binary")
|
||||
load("@py_deps//:requirements.bzl", "requirement")
|
||||
load("//ts:jest.bzl", "jest_test")
|
||||
|
||||
_i18n_files = [
|
||||
"i18n-translate.ts",
|
||||
"i18n-modules.ts",
|
||||
]
|
||||
|
||||
_generated = _i18n_files + [
|
||||
"backend_proto.d.ts",
|
||||
]
|
||||
|
||||
protobufjs_library(
|
||||
name = "backend_proto",
|
||||
proto = "//proto:backend_proto_lib",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
py_binary(
|
||||
name = "genfluent",
|
||||
srcs = [
|
||||
|
@ -31,10 +16,14 @@ py_binary(
|
|||
requirement("stringcase"),
|
||||
],
|
||||
)
|
||||
_i18n_generated = [
|
||||
"i18n/translate.ts",
|
||||
"i18n/modules.ts",
|
||||
]
|
||||
|
||||
genrule(
|
||||
name = "fluent_gen",
|
||||
outs = _i18n_files,
|
||||
outs = _i18n_generated,
|
||||
cmd = "$(location genfluent) $(location //rslib/i18n:strings.json) $(OUTS)",
|
||||
tools = [
|
||||
"genfluent",
|
||||
|
@ -42,13 +31,24 @@ genrule(
|
|||
],
|
||||
)
|
||||
|
||||
protobufjs_library(
|
||||
name = "backend_proto",
|
||||
proto = "//proto:backend_proto_lib",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
_generated = [
|
||||
"backend_proto.d.ts",
|
||||
] + _i18n_generated
|
||||
|
||||
typescript(
|
||||
name = "lib",
|
||||
srcs = glob(
|
||||
["*.ts"],
|
||||
exclude = _generated,
|
||||
),
|
||||
generated = [":" + file for file in _generated],
|
||||
generated = [
|
||||
":backend_proto.d.ts",
|
||||
":i18n/translate.ts",
|
||||
":i18n/modules.ts",
|
||||
],
|
||||
deps = [
|
||||
":backend_proto",
|
||||
"@npm//@fluent/bundle",
|
||||
|
@ -63,9 +63,19 @@ typescript(
|
|||
# Tests
|
||||
################
|
||||
|
||||
prettier_test(exclude = _generated)
|
||||
prettier_test(
|
||||
srcs = glob(
|
||||
["**/*.ts"],
|
||||
exclude = _generated,
|
||||
),
|
||||
)
|
||||
|
||||
eslint_test(exclude = _generated)
|
||||
eslint_test(
|
||||
srcs = glob(
|
||||
["**/*.ts"],
|
||||
exclude = _generated,
|
||||
),
|
||||
)
|
||||
|
||||
jest_test(
|
||||
deps = [
|
||||
|
|
|
@ -17,7 +17,7 @@ class Variable(TypedDict):
|
|||
|
||||
|
||||
def methods() -> str:
|
||||
out = [ 'import { translate } from "./i18n-bundles";' ]
|
||||
out = [ 'import { translate } from "./bundles";' ]
|
||||
for module in modules:
|
||||
for translation in module["translations"]:
|
||||
key = stringcase.camelcase(translation["key"].replace("-", "_"))
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../../bazel-bin/ts/lib/i18n-modules.ts
|
|
@ -1 +0,0 @@
|
|||
../../bazel-bin/ts/lib/i18n-translate.ts
|
3
ts/lib/i18n/index.ts
Normal file
3
ts/lib/i18n/index.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
export * from "./utils";
|
||||
export * as tr from "./translate";
|
||||
export { ModuleName } from "./modules";
|
1
ts/lib/i18n/modules.ts
Symbolic link
1
ts/lib/i18n/modules.ts
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../../bazel-bin/ts/lib/i18n/modules.ts
|
1
ts/lib/i18n/translate.ts
Symbolic link
1
ts/lib/i18n/translate.ts
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../../bazel-bin/ts/lib/i18n/translate.ts
|
|
@ -4,8 +4,8 @@
|
|||
import "intl-pluralrules";
|
||||
import { FluentBundle, FluentResource } from "@fluent/bundle";
|
||||
|
||||
import { firstLanguage, setBundles } from "./i18n-bundles";
|
||||
import type { ModuleName } from "./i18n-modules";
|
||||
import { firstLanguage, setBundles } from "./bundles";
|
||||
import type { ModuleName } from "./modules";
|
||||
|
||||
export function supportsVerticalText(): boolean {
|
||||
const firstLang = firstLanguage();
|
||||
|
@ -79,6 +79,3 @@ export async function setupI18n(args: { modules: ModuleName[] }): Promise<void>
|
|||
setBundles(...newBundles);
|
||||
langs.splice(0, langs.length, ...json.langs);
|
||||
}
|
||||
|
||||
export { ModuleName } from "./i18n-modules";
|
||||
export * as tr from "./i18n-translate";
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"include": ["*"],
|
||||
"include": ["*", "i18n/*"],
|
||||
"references": [],
|
||||
"compilerOptions": {
|
||||
"types": ["jest"]
|
||||
|
|
|
@ -4,12 +4,13 @@ load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin", "js_library")
|
|||
def typescript(
|
||||
name,
|
||||
srcs = None,
|
||||
exclude = [],
|
||||
generated = [],
|
||||
tsconfig = "tsconfig.json",
|
||||
visibility = ["//visibility:public"],
|
||||
**kwargs):
|
||||
if not srcs:
|
||||
srcs = native.glob(["**/*.ts"])
|
||||
srcs = native.glob(["**/*.ts"], exclude = exclude)
|
||||
|
||||
# all tsconfig files must be in the bazel-out folder
|
||||
copy_to_bin(
|
||||
|
|
Loading…
Reference in a new issue