diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b70951..ee24cb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,27 @@ cmake_minimum_required(VERSION 3.21) -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/translations DESTINATION ${CMAKE_SOURCE_DIR}/resources) \ No newline at end of file +function(setup_translations target) + if (DEFINED ENV{ECLIPSE_TRANSLATIONS_REPO_PATH}) + set(TRANSLATIONS_PATH $ENV{ECLIPSE_TRANSLATIONS_REPO_PATH}) + else() + set(TRANSLATIONS_PATH ${CMAKE_CURRENT_BINARY_DIR}/eclipse-translations) + endif() + + # Refresh translations on every build + add_custom_command( + TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${TRANSLATIONS_PATH}/translations + ${CMAKE_SOURCE_DIR}/resources/translations + COMMENT "Copying translations..." + ) + + # If using a local repo, set timestamp to a high value to disable translations updates + if (DEFINED ENV{ECLIPSE_TRANSLATIONS_REPO_PATH}) + set(TRANSLATIONS_UNIX_TIMESTAMP 9999999999) + else() + string(TIMESTAMP TRANSLATIONS_UNIX_TIMESTAMP "%s" UTC) + endif() + + target_compile_definitions(${target} PRIVATE ECLIPSE_TRANSLATION_TIMESTAMP=${TRANSLATIONS_UNIX_TIMESTAMP}) +endfunction() \ No newline at end of file diff --git a/README.md b/README.md index 53a75ca..57ac051 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Metadata is stored at the top of the file, and contains the following fields: ```json5 { "language-name": "English", // The name of the language in English - "language-code": "en", // The language code (ISO 639-1) + "language-code": "en_US", // The language code "language-native": "English", // The name of the language in its native language "language-charset": "default", // The character set of the language "language-fallback": "en", // The fallback language code (defaults to English) @@ -55,9 +55,9 @@ Supported values are: This will tell Eclipse which font to use for the language. -`language-fallback` is optional and defaults to `en`. +`language-fallback` is optional and defaults to `en_US`. If a translation is missing for a key in the current language, Eclipse will fall back to the specified language. -You can use this to avoid duplicating translations for similar languages (e.g. `es` and `pt`). +You can use this to avoid duplicating translations for similar languages. > Note: this field is not recursive, so if a translation is missing in the fallback language, it will not fall back further. \ No newline at end of file diff --git a/crowdin.yml b/crowdin.yml index d7b03c2..3308cb4 100644 --- a/crowdin.yml +++ b/crowdin.yml @@ -1,5 +1,5 @@ files: - - source: /translations/en.lang.json + - source: /translations/en_US.lang.json translation: /translations/%locale_with_underscore%.lang.json pull_request_title: Update translations commit_message: Update %language% translations diff --git a/translations/en.lang.json b/translations/en_US.lang.json similarity index 100% rename from translations/en.lang.json rename to translations/en_US.lang.json diff --git a/translations/uk.lang.json b/translations/uk_UA.lang.json similarity index 99% rename from translations/uk.lang.json rename to translations/uk_UA.lang.json index f7a98a7..7581f32 100644 --- a/translations/uk.lang.json +++ b/translations/uk_UA.lang.json @@ -1,6 +1,6 @@ { "language-name": "Ukrainian", - "language-code": "uk", + "language-code": "uk_UA", "language-native": "Українська", "language-charset": "cyrillic", "language-fallback": "en",