mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -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
|
licenses.json
|
||||||
vendor
|
vendor
|
||||||
i18n-translate.ts
|
lib/i18n/translate.ts
|
||||||
i18n-modules.ts
|
lib/i18n/modules.ts
|
||||||
backend_proto.d.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:prettier.bzl", "prettier_test")
|
||||||
load("//ts:eslint.bzl", "eslint_test")
|
load("//ts:eslint.bzl", "eslint_test")
|
||||||
load("//ts:protobuf.bzl", "protobufjs_library")
|
load("//ts:protobuf.bzl", "protobufjs_library")
|
||||||
load("//ts:typescript.bzl", "typescript")
|
load("//ts:typescript.bzl", "typescript")
|
||||||
load("@rules_python//python:defs.bzl", "py_binary")
|
|
||||||
load("@py_deps//:requirements.bzl", "requirement")
|
load("@py_deps//:requirements.bzl", "requirement")
|
||||||
load("//ts:jest.bzl", "jest_test")
|
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(
|
py_binary(
|
||||||
name = "genfluent",
|
name = "genfluent",
|
||||||
srcs = [
|
srcs = [
|
||||||
|
@ -31,10 +16,14 @@ py_binary(
|
||||||
requirement("stringcase"),
|
requirement("stringcase"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
_i18n_generated = [
|
||||||
|
"i18n/translate.ts",
|
||||||
|
"i18n/modules.ts",
|
||||||
|
]
|
||||||
|
|
||||||
genrule(
|
genrule(
|
||||||
name = "fluent_gen",
|
name = "fluent_gen",
|
||||||
outs = _i18n_files,
|
outs = _i18n_generated,
|
||||||
cmd = "$(location genfluent) $(location //rslib/i18n:strings.json) $(OUTS)",
|
cmd = "$(location genfluent) $(location //rslib/i18n:strings.json) $(OUTS)",
|
||||||
tools = [
|
tools = [
|
||||||
"genfluent",
|
"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(
|
typescript(
|
||||||
name = "lib",
|
name = "lib",
|
||||||
srcs = glob(
|
|
||||||
["*.ts"],
|
|
||||||
exclude = _generated,
|
exclude = _generated,
|
||||||
),
|
generated = [
|
||||||
generated = [":" + file for file in _generated],
|
":backend_proto.d.ts",
|
||||||
|
":i18n/translate.ts",
|
||||||
|
":i18n/modules.ts",
|
||||||
|
],
|
||||||
deps = [
|
deps = [
|
||||||
":backend_proto",
|
":backend_proto",
|
||||||
"@npm//@fluent/bundle",
|
"@npm//@fluent/bundle",
|
||||||
|
@ -63,9 +63,19 @@ typescript(
|
||||||
# Tests
|
# 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(
|
jest_test(
|
||||||
deps = [
|
deps = [
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Variable(TypedDict):
|
||||||
|
|
||||||
|
|
||||||
def methods() -> str:
|
def methods() -> str:
|
||||||
out = [ 'import { translate } from "./i18n-bundles";' ]
|
out = [ 'import { translate } from "./bundles";' ]
|
||||||
for module in modules:
|
for module in modules:
|
||||||
for translation in module["translations"]:
|
for translation in module["translations"]:
|
||||||
key = stringcase.camelcase(translation["key"].replace("-", "_"))
|
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 "intl-pluralrules";
|
||||||
import { FluentBundle, FluentResource } from "@fluent/bundle";
|
import { FluentBundle, FluentResource } from "@fluent/bundle";
|
||||||
|
|
||||||
import { firstLanguage, setBundles } from "./i18n-bundles";
|
import { firstLanguage, setBundles } from "./bundles";
|
||||||
import type { ModuleName } from "./i18n-modules";
|
import type { ModuleName } from "./modules";
|
||||||
|
|
||||||
export function supportsVerticalText(): boolean {
|
export function supportsVerticalText(): boolean {
|
||||||
const firstLang = firstLanguage();
|
const firstLang = firstLanguage();
|
||||||
|
@ -79,6 +79,3 @@ export async function setupI18n(args: { modules: ModuleName[] }): Promise<void>
|
||||||
setBundles(...newBundles);
|
setBundles(...newBundles);
|
||||||
langs.splice(0, langs.length, ...json.langs);
|
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",
|
"extends": "../tsconfig.json",
|
||||||
"include": ["*"],
|
"include": ["*", "i18n/*"],
|
||||||
"references": [],
|
"references": [],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"types": ["jest"]
|
"types": ["jest"]
|
||||||
|
|
|
@ -4,12 +4,13 @@ load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin", "js_library")
|
||||||
def typescript(
|
def typescript(
|
||||||
name,
|
name,
|
||||||
srcs = None,
|
srcs = None,
|
||||||
|
exclude = [],
|
||||||
generated = [],
|
generated = [],
|
||||||
tsconfig = "tsconfig.json",
|
tsconfig = "tsconfig.json",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
**kwargs):
|
**kwargs):
|
||||||
if not srcs:
|
if not srcs:
|
||||||
srcs = native.glob(["**/*.ts"])
|
srcs = native.glob(["**/*.ts"], exclude = exclude)
|
||||||
|
|
||||||
# all tsconfig files must be in the bazel-out folder
|
# all tsconfig files must be in the bazel-out folder
|
||||||
copy_to_bin(
|
copy_to_bin(
|
||||||
|
|
Loading…
Reference in a new issue