Skip to content

Commit

Permalink
use locale instead of ISO 639-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Prevter committed Jan 2, 2025
1 parent 82a5b2f commit 1fac595
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
26 changes: 25 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
cmake_minimum_required(VERSION 3.21)

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/translations DESTINATION ${CMAKE_SOURCE_DIR}/resources)
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()
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
2 changes: 1 addition & 1 deletion crowdin.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion translations/uk.lang.json → translations/uk_UA.lang.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"language-name": "Ukrainian",
"language-code": "uk",
"language-code": "uk_UA",
"language-native": "Українська",
"language-charset": "cyrillic",
"language-fallback": "en",
Expand Down

0 comments on commit 1fac595

Please sign in to comment.