| load("@bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin") |
| load("@bazel_lib//lib:write_source_files.bzl", "write_source_files") |
| load("@npm//:@lit/localize-tools/package_json.bzl", lit_localize_bin = "bin") |
| load("//src/lit-locales:target_locales.bzl", "get_interchange_files_list") |
| load("//src/lit-locales/normalize_xliff_files:defs.bzl", "normalize_xliff_files") |
| load("//tools:common_js_project.bzl", "common_js_project") |
| load(":defs.bzl", "lit_localize", "non_normalized_source_golden_dir", "source_golden_dir") |
| load(":target_locales.bzl", "get_interchange_file_path", "target_locales") |
| |
| copy_to_bin( |
| name = "interchange_files", |
| srcs = glob(["source/*.xlf"]), |
| visibility = ["//tools/syncTranslations:__pkg__"], |
| ) |
| |
| # Source code that uses msg() to localize strings. |
| filegroup( |
| name = "localized_code", |
| srcs = [ |
| "//src/features/autoRefresh/presentation/options", |
| "//src/features/avatars/presentation/options", |
| "//src/features/batchLock/presentation/options", |
| "//src/features/blockDrafts/presentation/options", |
| "//src/features/bulkMove/presentation/options", |
| "//src/features/bulkMove/ui/components:source_code", |
| "//src/features/bulkReportReplies/presentation/options", |
| "//src/features/bulkReportReplies/ui/components:source_code", |
| "//src/features/ccDarkTheme/presentation/options", |
| "//src/features/ccDragAndDropFix/presentation/options", |
| "//src/features/ccForceHideDrawer/presentation/options", |
| "//src/features/enhancedAnnouncementsDot/presentation/options", |
| "//src/features/extraInfo/presentation/options", |
| "//src/features/fixPEKB381989895/presentation/options", |
| "//src/features/fixedToolbar/presentation/options", |
| "//src/features/flattenThreads/presentation/options", |
| "//src/features/flattenThreads/ui/components:source_code", |
| "//src/features/imageMaxHeight/presentation/options", |
| "//src/features/increaseContrast/presentation/options", |
| "//src/features/infiniteScroll/presentation/options", |
| "//src/features/interopThreadPage/presentation/options", |
| "//src/features/linkDialogFix/presentation/options", |
| "//src/features/loadDrafts/presentation/options", |
| "//src/features/previousPosts/presentation/options", |
| "//src/features/profileIndicator/presentation/options", |
| "//src/features/redirect/presentation/options", |
| "//src/features/repositionExpandThread/presentation/options", |
| "//src/features/stickySidebarHeaders/presentation/options", |
| "//src/features/threadToolbar/ui/components:source_code", |
| "//src/features/uiSpacing/presentation/options", |
| "//src/options/presentation/data", |
| "//src/options/presentation/utils", |
| "//src/options/ui/components:source_code", |
| "//src/presentation/i18n/lit", |
| "//src/ui/components/forumDestinationPicker:source_code", |
| "//src/updateNotifier/ui/components:source_code", |
| ], |
| ) |
| |
| lit_localize( |
| name = "generated_files", |
| operation = "build", |
| ) |
| |
| common_js_project( |
| name = "lit-locales", |
| srcs = [ |
| ":generated_files", |
| ], |
| visibility = [ |
| "//src:__subpackages__", |
| ], |
| ) |
| |
| lit_localize( |
| name = "non_normalized_source_golden_files", |
| operation = "extract", |
| ) |
| |
| normalize_xliff_files( |
| name = "source_golden_files", |
| srcs = get_interchange_files_list(non_normalized_source_golden_dir), |
| outs = get_interchange_files_list(source_golden_dir), |
| ) |
| |
| write_source_files( |
| name = "extract", |
| diff_test = True, |
| diff_test_failure_message = """ |
| |
| The lit-localize interchange XLIFF files are not up to date with |
| the messages in the source code. |
| |
| To fix this, update this and other interchange files by running: |
| |
| bazel run {{SUGGESTED_UPDATE_TARGET}} |
| |
| To update *only* the file that needs updating, run: |
| |
| bazel run {{TARGET}} |
| |
| """, |
| file_missing_failure_message = """ |
| |
| One or more new languages have been added to lit-localize's targetLocales |
| but their corresponding interchange XLIFF files don't exist. |
| |
| To fix this, generate this and other missing files by running: |
| |
| bazel run {{SUGGESTED_UPDATE_TARGET}} |
| |
| To generate *only* the file that needs creation, run: |
| |
| bazel run {{TARGET}} |
| |
| """, |
| files = { |
| get_interchange_file_path( |
| locale, |
| directory = "source", |
| ): get_interchange_file_path( |
| locale, |
| directory = "source_golden", |
| ) |
| for locale in target_locales |
| }, |
| ) |
| |
| lit_localize_bin.lit_localize_binary( |
| name = "lit_localize", |
| ) |