Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up language strings, add openomf-translations submodule #737

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
uses: Eeems-Org/apt-cache-action@v1.3
Expand Down Expand Up @@ -74,7 +76,10 @@ jobs:
key: omf2097-assets.zip

- name: Extract omf 2097 assets
run: unzip -j omf2097-assets.zip -d build-test/resources
shell: bash
run: |
unzip -j omf2097-assets.zip -d build-test/resources
rm -f build-test/resources/{ENGLISH.DAT,GERMAN.DAT}

- name: Install pytest requirements
run: |
Expand Down Expand Up @@ -108,6 +113,8 @@ jobs:
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- uses: actions/checkout@v4
with:
submodules: true
- name: Check out VCPKG
# must be checked out *after* openomf.git
uses: actions/checkout@v4
Expand Down Expand Up @@ -147,10 +154,11 @@ jobs:
key: omf2097-assets.zip

- name: Extract omf 2097 assets
shell: bash
run: |
Expand-Archive omf2097-assets.zip -PassThru
mkdir install/openomf/resources
Move-Item -Path omf2097-assets/OMF2097/* -Destination install/openomf/resources/ -Force -PassThru
mkdir -p install/openomf/resources
unzip -j omf2097-assets.zip -d install/openomf/resources
rm -f install/openomf/resources/{ENGLISH.DAT,GERMAN.DAT}

- name: Install openomf
run: cmake --install build-msvc --config Release --prefix install
Expand Down Expand Up @@ -182,6 +190,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install Ubuntu Dependencies
uses: Eeems-Org/apt-cache-action@v1.3
Expand Down Expand Up @@ -220,7 +230,9 @@ jobs:
key: omf2097-assets.zip

- name: Extract omf 2097 assets
run: unzip -j omf2097-assets.zip -d build-release/release/usr/share/games/openomf
run: |
unzip -j omf2097-assets.zip -d build-release/release/usr/share/games/openomf
rm -f build-release/release/usr/share/games/openomf/{ENGLISH.DAT,GERMAN.DAT}

- name: Generate TGZ package
run: tar cvfz ${GITHUB_WORKSPACE}/openomf_${{ env.OPENOMF_VERSION }}-${{ steps.slug.outputs.sha8 }}_linux_amd64.tar.gz -C build-release/release/ .
Expand Down Expand Up @@ -263,6 +275,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install Mac Dependencies
run: |
Expand Down Expand Up @@ -295,7 +309,10 @@ jobs:
key: omf2097-assets.zip

- name: Extract omf 2097 assets
run: unzip -j omf2097-assets.zip -d build-release/release/usr/share/games/openomf
shell: bash
run: |
unzip -j omf2097-assets.zip -d build-release/release/usr/share/games/openomf
rm -f build-release/release/usr/share/games/openomf/{ENGLISH.DAT,GERMAN.DAT}

- name: Get short SHA
id: slug
Expand Down Expand Up @@ -323,6 +340,9 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
# mingw does not build languages
submodules: false

- name: Install apt Dependencies
uses: Eeems-Org/apt-cache-action@v1.3
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "resources/translations"]
path = resources/translations
url = git@github.com:omf2097/openomf-translations.git
branch = master
55 changes: 24 additions & 31 deletions cmake-scripts/BuildLanguages.cmake
Original file line number Diff line number Diff line change
@@ -1,58 +1,51 @@
#
# BuildLanguages.cmake has one job:
# if option BUILD_LANGUAGES is on, builds the .LNG files from resources/translations/*.TXT
#

if(NOT BUILD_LANGUAGES)
return()
endif()

# OMF 2097 Epic Challenge Arena
set(LANG_STRCOUNT 1013)
set(OMF_LANGS ENGLISH GERMAN)
# OpenOMF-specific
set(LANG2_STRCOUNT 1)
set(OPENOMF_LANGS DANISH)

if(WIN32)
set(LANGUAGE_INSTALL_PATH "openomf/resources/")
else()
set(LANGUAGE_INSTALL_PATH "share/games/openomf/")
endif()

# glob all language sources
set(LANG_SRC "${PROJECT_SOURCE_DIR}/resources/translations")
file(GLOB OPENOMF_LANGS
LIST_DIRECTORIES false
CONFIGURE_DEPENDS
"${LANG_SRC}/*.TXT"
)

file(READ "${LANG_SRC}/langstr_count" Lang_Count)
string(REGEX REPLACE "\n+$" "" Lang_Count "${Lang_Count}")

# generate custom target info
set(BUILD_LANG_COMMANDS)
set(BUILD_LANG_SOURCES)
foreach(LANG ${OMF_LANGS})
set(TXT2 "${PROJECT_SOURCE_DIR}/resources/${LANG}2.TXT")
set(DAT2 "${CMAKE_CURRENT_BINARY_DIR}/resources/${LANG}.DAT2")
list(APPEND BUILD_LANG_SORUCES "${TXT2}")
list(APPEND BUILD_LANG_COMMANDS
DEPENDS "${TXT2}"
BYPRODUCTS "${DAT2}"
COMMAND ${CMAKE_COMMAND} -E echo_append "${LANG}, "
COMMAND "$<TARGET_FILE:languagetool>" -i "${TXT2}" -o "${DAT2}" --check-count ${LANG2_STRCOUNT}
)
install(FILES "${DAT2}" DESTINATION "${LANGUAGE_INSTALL_PATH}")
endforeach()
foreach(LANG ${OPENOMF_LANGS})
set(TXT "${PROJECT_SOURCE_DIR}/resources/${LANG}.TXT")
set(TXT2 "${PROJECT_SOURCE_DIR}/resources/${LANG}2.TXT")
foreach(TXT ${OPENOMF_LANGS})
get_filename_component(LANG "${TXT}" NAME_WE)
set(LNG "${CMAKE_CURRENT_BINARY_DIR}/resources/${LANG}.LNG")
set(LNG2 "${CMAKE_CURRENT_BINARY_DIR}/resources/${LANG}.LNG2")
list(APPEND BUILD_LANG_SORUCES "${TXT}" "${TXT2}")
list(APPEND BUILD_LANG_SORUCES "${TXT}")
list(APPEND BUILD_LANG_COMMANDS
DEPENDS "${TXT}" "${TXT2}"
BYPRODUCTS "${LNG}" "{LNG2}"
DEPENDS "${TXT}"
BYPRODUCTS "${LNG}"
COMMAND ${CMAKE_COMMAND} -E echo_append "${LANG}, "
COMMAND "$<TARGET_FILE:languagetool>" -i "${TXT}" -o "${LNG}" --check-count ${LANG_STRCOUNT}
COMMAND "$<TARGET_FILE:languagetool>" -i "${TXT2}" -o "${LNG2}" --check-count ${LANG2_STRCOUNT}
COMMAND "$<TARGET_FILE:languagetool>" --import "${TXT}" --output "${LNG}" --check-count "${Lang_Count}"
)
install(FILES "${LNG}" "${LNG2}" DESTINATION "${LANGUAGE_INSTALL_PATH}")
install(FILES "${LNG}" DESTINATION "${LANGUAGE_INSTALL_PATH}")
endforeach()



add_custom_target(build_languages
COMMAND ${CMAKE_COMMAND} -E echo_append "Building Languages... "
${BUILD_LANG_COMMANDS}
COMMAND ${CMAKE_COMMAND} -E echo_append "done"
)
target_sources(build_languages PRIVATE ${BUILD_LANG_SORUCES})
target_sources(build_languages PRIVATE ${BUILD_LANG_SOURCES})
add_dependencies(openomf build_languages)
add_dependencies(build_languages languagetool)
Loading
Loading