mirror of
https://github.com/aseprite/aseprite.git
synced 2024-09-01 20:49:47 +00:00
[i18n] Clone and add "strings" repo in "data/strings.git" to get updated translations
As we've moved all the translations to the strings
repo (06a852d1d4
), to facilitate the
i18n work now we load translations from "data/strings" and from
"data/strings.git" folders, where "strings.git" is a clone of the
strings repo (https://github.com/aseprite/strings.git) in
"build/bin/data/strings.git".
This clone is executed automatically in the cmake configuration stage
so it's transparent for the developer and the result is like having
the translations available in the same "aseprite" repo.
This commit is contained in:
parent
5900605549
commit
af73adeab0
@ -1,5 +1,5 @@
|
||||
# Aseprite
|
||||
# Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
# Copyright (C) 2019-2024 Igara Studio S.A.
|
||||
# Copyright (C) 2001-2018 David Capello
|
||||
|
||||
######################################################################
|
||||
@ -148,10 +148,30 @@ endif()
|
||||
add_subdirectory(app)
|
||||
|
||||
######################################################################
|
||||
# Copy data/ directory target
|
||||
# Output bin/data/ directory where we are going to copy data files
|
||||
|
||||
set(DATA_OUTPUT_DIR ${CMAKE_BINARY_DIR}/bin/data)
|
||||
|
||||
######################################################################
|
||||
# Clone "strings" repo with translations into bin/data/strings.git
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
clone_strings
|
||||
GIT_REPOSITORY https://github.com/aseprite/strings.git
|
||||
GIT_TAG origin/main
|
||||
SOURCE_DIR ${DATA_OUTPUT_DIR}/strings.git
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND "")
|
||||
FetchContent_MakeAvailable(clone_strings)
|
||||
add_custom_target(clone_strings DEPENDS clone_strings)
|
||||
|
||||
######################################################################
|
||||
# Copy data/ directory target into bin/data/
|
||||
|
||||
file(GLOB_RECURSE src_data_files
|
||||
RELATIVE ${SOURCE_DATA_DIR}/ "${SOURCE_DATA_DIR}/*.*")
|
||||
foreach(fn ${src_data_files})
|
||||
@ -162,6 +182,15 @@ foreach(fn ${src_data_files})
|
||||
list(APPEND out_data_files ${DATA_OUTPUT_DIR}/${fn})
|
||||
endforeach()
|
||||
|
||||
# Copy original en.ini to strings.git/en.ini to keep it updated. We
|
||||
# have to manually sync the "en.ini" file in the "strings" repo from
|
||||
# the "aseprite" repo.
|
||||
add_custom_command(
|
||||
OUTPUT ${DATA_OUTPUT_DIR}/en.ini
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SOURCE_DATA_DIR}/strings/en.ini ${DATA_OUTPUT_DIR}/strings.git/en.ini
|
||||
MAIN_DEPENDENCY ${SOURCE_DATA_DIR}/strings/en.ini)
|
||||
list(APPEND out_data_files ${DATA_OUTPUT_DIR}/strings.git/en.ini)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${DATA_OUTPUT_DIR}/README.md
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../README.md ${DATA_OUTPUT_DIR}/README.md
|
||||
@ -180,7 +209,7 @@ add_custom_command(
|
||||
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/../docs/LICENSES.md)
|
||||
list(APPEND out_data_files ${DATA_OUTPUT_DIR}/docs/LICENSES.md)
|
||||
|
||||
add_custom_target(copy_data DEPENDS ${out_data_files})
|
||||
add_custom_target(copy_data DEPENDS clone_strings ${out_data_files})
|
||||
|
||||
######################################################################
|
||||
# Aseprite application
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2023 Igara Studio S.A.
|
||||
// Copyright (C) 2023-2024 Igara Studio S.A.
|
||||
// Copyright (C) 2016-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -53,15 +53,20 @@ std::set<LangInfo> Strings::availableLanguages() const
|
||||
{
|
||||
std::set<LangInfo> result;
|
||||
|
||||
// Add languages in data/strings/
|
||||
// Add languages in data/strings/ + data/strings.git/
|
||||
ResourceFinder rf;
|
||||
rf.includeDataDir("strings");
|
||||
rf.includeDataDir("strings.git");
|
||||
while (rf.next()) {
|
||||
const std::string stringsPath = rf.filename();
|
||||
if (!base::is_directory(stringsPath))
|
||||
continue;
|
||||
|
||||
for (const auto& fn : base::list_files(stringsPath)) {
|
||||
// Ignore README/LICENSE files.
|
||||
if (base::get_file_extension(fn) != "ini")
|
||||
continue;
|
||||
|
||||
const std::string langId = base::get_file_title(fn);
|
||||
std::string path = base::join_path(stringsPath, fn);
|
||||
std::string displayName = langId;
|
||||
@ -123,14 +128,15 @@ void Strings::loadLanguage(const std::string& langId)
|
||||
void Strings::loadStringsFromDataDir(const std::string& langId)
|
||||
{
|
||||
// Load the English language file from the Aseprite data directory (so we have the most update list of strings)
|
||||
LOG("I18N: Loading strings/%s.ini file\n", langId.c_str());
|
||||
LOG("I18N: Loading %s.ini file\n", langId.c_str());
|
||||
ResourceFinder rf;
|
||||
rf.includeDataDir(("strings/" + langId + ".ini").c_str());
|
||||
rf.includeDataDir(base::join_path("strings", langId + ".ini").c_str());
|
||||
rf.includeDataDir(base::join_path("strings.git", langId + ".ini").c_str());
|
||||
if (!rf.findFirst()) {
|
||||
LOG("strings/%s.ini was not found", langId.c_str());
|
||||
LOG("I18N: %s.ini was not found\n", langId.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
LOG("I18N: %s found\n", rf.filename().c_str());
|
||||
loadStringsFromFile(rf.filename());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user