Skip to content

Commit

Permalink
move translations
Browse files Browse the repository at this point in the history
  • Loading branch information
sithlord48 committed Aug 30, 2022
1 parent 116b15a commit 7ac0a18
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 47 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ jobs:
export VERSION="${{env.BCVersion}}"
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${{ matrix.config.ff7tkPrefix }}/lib
export PATH=$PATH:/opt/Qt/${{env.QtVersion}}/gcc_64/libexec
mkdir -p ./appdir/usr/share/ff7tk/lang
mkdir -p ./appdir/usr/share/ff7tk/translations
mkdir -p ./appdir/usr/plugins/iconengines
cp /opt/Qt/${{ env.QtVersion }}/gcc_64/plugins/iconengines/libqsvgicon.so ./appdir/usr/plugins/iconengines/libqsvgicon.so
cp ${{matrix.config.ff7tkPrefix}}/share/ff7tk/lang/*.qm ./appdir/usr/share/ff7tk/lang
cp ${{matrix.config.ff7tkPrefix}}/share/ff7tk/translations/*.qm ./appdir/usr/share/ff7tk/translations
./linuxdeploy-x86_64.AppImage --appdir=appdir --output appimage \
-e src/blackchocobo \
-d deploy/org.sithlord48.blackchocobo.desktop \
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)

add_subdirectory(deploy)
add_subdirectory(icons)
add_subdirectory(lang)
add_subdirectory(translations)
add_subdirectory(qhexedit)
add_subdirectory(src)
15 changes: 9 additions & 6 deletions src/bcsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,19 @@ void BCSettings::initSettings()
if (settings->value(SETTINGS::REGION).isNull())
settings->setValue(SETTINGS::REGION, QStringLiteral("NTSC-U"));

QDir translationDir(QStringLiteral("%1/%2").arg(QCoreApplication::applicationDirPath(), QStringLiteral("lang")));
QStringList nameFilter{QStringLiteral("bchoco_*.qm")};
QDir translationDir(QStringLiteral("%1/%2").arg(QCoreApplication::applicationDirPath(), QStringLiteral("translations")));
QStringList nameFilter{QStringLiteral("blackchocobo_*.qm")};
if (translationDir.entryList(nameFilter, QDir::Files, QDir::Name).isEmpty()) {
translationDir.setPath(QStringLiteral("%1/../share/blackchocobo/lang").arg(QCoreApplication::applicationDirPath()));
translationDir.setPath(QStringLiteral("%1/../translations").arg(QCoreApplication::applicationDirPath()));
if (translationDir.entryList(nameFilter, QDir::Files, QDir::Name).isEmpty()) {
translationDir.setPath(QStringLiteral("%1/%2").arg(QDir::homePath(), QStringLiteral(".local/share/blackchocobo/lang")));
translationDir.setPath(QStringLiteral("%1/../share/blackchocobo/translations").arg(QCoreApplication::applicationDirPath()));
if (translationDir.entryList(nameFilter, QDir::Files, QDir::Name).isEmpty()) {
translationDir.setPath(QStringLiteral("/usr/local/share/blackchocobo/lang"));
translationDir.setPath(QStringLiteral("%1/%2").arg(QDir::homePath(), QStringLiteral(".local/share/blackchocobo/translations")));
if (translationDir.entryList(nameFilter, QDir::Files, QDir::Name).isEmpty()) {
translationDir.setPath(QStringLiteral("/usr/share/blackchocobo/lang"));
translationDir.setPath(QStringLiteral("/usr/local/share/blackchocobo/translations"));
if (translationDir.entryList(nameFilter, QDir::Files, QDir::Name).isEmpty()) {
translationDir.setPath(QStringLiteral("/usr/share/blackchocobo/translations"));
}
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/blackchocobo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ void BlackChocobo::detectTranslations()
{
m_translations.clear();

QStringList nameFilter ={QStringLiteral("bchoco_*.qm")};
QStringList nameFilter ={QStringLiteral("blackchocobo_*.qm")};
QMap<QString, QTranslator *> app_translations;
QDir dir (QStringLiteral("%1").arg(BCSettings::value(SETTINGS::LANGPATH).toString()));
QStringList langList = dir.entryList(nameFilter,QDir::Files, QDir::Name);
for (const QString &translation : langList) {
QTranslator *translator = new QTranslator;
std::ignore = translator->load(translation, dir.absolutePath());
QString lang = translation.mid(7, 2);
QString lang = translation.mid(13, 2);
app_translations.insert(lang, translator);
bool currentLang = (BCSettings::value(SETTINGS::LANG, QStringLiteral("en")).toString() == lang);
if (currentLang) {
Expand All @@ -133,19 +133,19 @@ void BlackChocobo::detectTranslations()

QMap<QString, QTranslator *> ff7tk_translations;
nameFilter = QStringList{QStringLiteral("ff7tk_*.qm")};
dir.setPath(QStringLiteral("%1/%2").arg(QCoreApplication::applicationDirPath(), QStringLiteral("lang")));
dir.setPath(QStringLiteral("%1/%2").arg(QCoreApplication::applicationDirPath(), QStringLiteral("translations")));
langList = dir.entryList(nameFilter, QDir::Files, QDir::Name);
if (langList.isEmpty()) {
dir.setPath(QStringLiteral("%1/../share/ff7tk/lang").arg(QCoreApplication::applicationDirPath()));
dir.setPath(QStringLiteral("%1/../share/ff7tk/translations").arg(QCoreApplication::applicationDirPath()));
langList = dir.entryList(nameFilter, QDir::Files, QDir::Name);
if(langList.isEmpty()) {
dir.setPath(QStringLiteral("%1/%2").arg(QDir::homePath(), QStringLiteral(".local/share/ff7tk/lang")));
dir.setPath(QStringLiteral("%1/%2").arg(QDir::homePath(), QStringLiteral(".local/share/ff7tk/translations")));
langList = dir.entryList(nameFilter, QDir::Files, QDir::Name);
if(langList.isEmpty()) {
dir.setPath(QStringLiteral("/usr/local/share/ff7tk/lang"));
dir.setPath(QStringLiteral("/usr/local/share/ff7tk/translations"));
langList = dir.entryList(nameFilter, QDir::Files, QDir::Name);
if(langList.isEmpty()) {
dir.setPath(QStringLiteral("/usr/share/ff7tk/lang"));
dir.setPath(QStringLiteral("/usr/share/ff7tk/translations"));
langList = dir.entryList(nameFilter, QDir::Files, QDir::Name);
}
}
Expand All @@ -166,7 +166,7 @@ void BlackChocobo::detectTranslations()
dir.setPath(QStringLiteral("%1/%2").arg(QCoreApplication::applicationDirPath(), QStringLiteral("translations")));
langList = dir.entryList(nameFilter, QDir::Files, QDir::Name);
if (langList.isEmpty()) {
dir.setPath(QStringLiteral("%1/%2").arg(QCoreApplication::applicationDirPath(), QStringLiteral("lang")));
dir.setPath(QStringLiteral("%1/%2").arg(QCoreApplication::applicationDirPath(), QStringLiteral("translations")));
langList = dir.entryList(nameFilter, QDir::Files, QDir::Name);
if (langList.isEmpty()) {
dir.setPath(QStringLiteral("%1/../share/qt/translations").arg(QCoreApplication::applicationDirPath()));
Expand Down
4 changes: 2 additions & 2 deletions src/dialogs/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ Options::Options(QWidget *parent) : QDialog(parent)
btn->setIconSize(iconSize);

QDir dir (BCSettings::value(SETTINGS::LANGPATH).toString());
QStringList langList = dir.entryList(QStringList("bchoco_*.qm"), QDir::Files, QDir::Name);
QStringList langList = dir.entryList(QStringList("blackchocobo_*.qm"), QDir::Files, QDir::Name);
for (const QString &translation : langList) {
auto translator = new QTranslator;
std::ignore = translator->load(translation, dir.absolutePath());
QString lang = translation.mid(7, 2);
QString lang = translation.mid(13, 2);
ui->comboLanguage->addItem(translator->translate("MainWindow", "TRANSLATE TO YOUR LANGUAGE NAME"), lang);
}
ui->comboLanguage->setCurrentIndex(ui->comboLanguage->findData(BCSettings::value(SETTINGS::LANG, QStringLiteral("en"))));
Expand Down
40 changes: 20 additions & 20 deletions lang/CMakeLists.txt → translations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,37 @@ find_package(Qt6 ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE COMPONENTS
)

set ( blackchocobo_TRS
bchoco_de.ts
bchoco_en.ts
bchoco_es.ts
bchoco_fr.ts
bchoco_it.ts
bchoco_ja.ts
bchoco_pl.ts
bchoco_re.ts
blackchocobo_de.ts
blackchocobo_en.ts
blackchocobo_es.ts
blackchocobo_fr.ts
blackchocobo_it.ts
blackchocobo_ja.ts
blackchocobo_pl.ts
blackchocobo_re.ts
)

set (FF7TK_TRS
${ff7tk_DIR}/../../../share/ff7tk/lang/ff7tk_de.qm
${ff7tk_DIR}/../../../share/ff7tk/lang/ff7tk_en.qm
${ff7tk_DIR}/../../../share/ff7tk/lang/ff7tk_es.qm
${ff7tk_DIR}/../../../share/ff7tk/lang/ff7tk_fr.qm
${ff7tk_DIR}/../../../share/ff7tk/lang/ff7tk_it.qm
${ff7tk_DIR}/../../../share/ff7tk/lang/ff7tk_ja.qm
${ff7tk_DIR}/../../../share/ff7tk/lang/ff7tk_pl.qm
${ff7tk_DIR}/../../../share/ff7tk/lang/ff7tk_re.qm
${ff7tk_DIR}/../../../share/ff7tk/translations/ff7tk_de.qm
${ff7tk_DIR}/../../../share/ff7tk/translations/ff7tk_en.qm
${ff7tk_DIR}/../../../share/ff7tk/translations/ff7tk_es.qm
${ff7tk_DIR}/../../../share/ff7tk/translations/ff7tk_fr.qm
${ff7tk_DIR}/../../../share/ff7tk/translations/ff7tk_it.qm
${ff7tk_DIR}/../../../share/ff7tk/translations/ff7tk_ja.qm
${ff7tk_DIR}/../../../share/ff7tk/translations/ff7tk_pl.qm
${ff7tk_DIR}/../../../share/ff7tk/translations/ff7tk_re.qm
)

qt_create_translation(TRS ${CMAKE_SOURCE_DIR} ${blackchocobo_TRS} OPTIONS -no-ui-lines -locations none)
add_custom_target(app_translations ALL DEPENDS ${TRS})

if(UNIX AND NOT APPLE)
install(FILES ${TRS} DESTINATION share/blackchocobo/lang)
install(FILES ${TRS} DESTINATION share/blackchocobo/translations)
elseif(WIN32)
install(FILES ${TRS} DESTINATION lang)
install(FILES ${FF7TK_TRS} DESTINATION lang)
install(FILES ${TRS} DESTINATION translations)
install(FILES ${FF7TK_TRS} DESTINATION translations)
elseif(APPLE)
set(MAC_LANG_PATH Black_Chocobo.app/Contents/MacOS/lang)
set(MAC_LANG_PATH Black_Chocobo.app/Contents/MacOS/translations)
set(MAC_QT_LANG_PATH ${Qt${QT_DEFAULT_MAJOR_VERSION}_DIR}/../../../translations)
install(FILES ${TRS} DESTINATION ${MAC_LANG_PATH})
install(FILES ${FF7TK_TRS} DESTINATION ${MAC_LANG_PATH})
Expand Down
7 changes: 6 additions & 1 deletion lang/bchoco_de.ts → translations/blackchocobo_de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1583,9 +1583,14 @@ Trigger, Tutorial zeigt</translation>
<message>
<source>Change Widget Style
Fusion is recommended Other themes may not obey the color palette or contain graphical issues.</source>
<translation type="unfinished">Ändern Sie den Widget-Stil
<translation type="obsolete">Ändern Sie den Widget-Stil
Fusion wird empfohlen. Andere Themen entsprechen möglicherweise nicht der Farbpalette oder weisen grafische Probleme auf.</translation>
</message>
<message>
<source>Fusion is the recommended theme
Other themes may contain graphical issues.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PartyTab</name>
Expand Down
7 changes: 6 additions & 1 deletion lang/bchoco_en.ts → translations/blackchocobo_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1580,9 +1580,14 @@ trigger showing that tutorial</translation>
<message>
<source>Change Widget Style
Fusion is recommended Other themes may not obey the color palette or contain graphical issues.</source>
<translation>Change Widget Style
<translation type="vanished">Change Widget Style
Fusion is recommended Other themes may not obey the color palette or contain graphical issues.</translation>
</message>
<message>
<source>Fusion is the recommended theme
Other themes may contain graphical issues.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PartyTab</name>
Expand Down
7 changes: 6 additions & 1 deletion lang/bchoco_es.ts → translations/blackchocobo_es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1582,9 +1582,14 @@ trigger showing that tutorial</source>
<message>
<source>Change Widget Style
Fusion is recommended Other themes may not obey the color palette or contain graphical issues.</source>
<translation type="unfinished">Cambiar el estilo del widget
<translation type="obsolete">Cambiar el estilo del widget
Se recomienda Fusion. Es posible que otros temas no obedezcan a la paleta de colores o contengan problemas gráficos.</translation>
</message>
<message>
<source>Fusion is the recommended theme
Other themes may contain graphical issues.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PartyTab</name>
Expand Down
7 changes: 6 additions & 1 deletion lang/bchoco_fr.ts → translations/blackchocobo_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1584,9 +1584,14 @@ le tutoriel sera affiché directement</translation>
<message>
<source>Change Widget Style
Fusion is recommended Other themes may not obey the color palette or contain graphical issues.</source>
<translation type="unfinished">Changer le style des widgets
<translation type="obsolete">Changer le style des widgets
La fusion est recommandée D&apos;autres thèmes peuvent ne pas respecter la palette de couleurs ou contenir des problèmes graphiques.</translation>
</message>
<message>
<source>Fusion is the recommended theme
Other themes may contain graphical issues.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PartyTab</name>
Expand Down
7 changes: 6 additions & 1 deletion lang/bchoco_it.ts → translations/blackchocobo_it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1580,9 +1580,14 @@ Seleziona una posizione per salvare i file delle statistiche del personaggio</tr
<message>
<source>Change Widget Style
Fusion is recommended Other themes may not obey the color palette or contain graphical issues.</source>
<translation type="unfinished">Cambia stile widget
<translation type="obsolete">Cambia stile widget
Si consiglia Fusion Altri temi potrebbero non rispettare la tavolozza dei colori o contenere problemi grafici.</translation>
</message>
<message>
<source>Fusion is the recommended theme
Other themes may contain graphical issues.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PartyTab</name>
Expand Down
7 changes: 6 additions & 1 deletion lang/bchoco_ja.ts → translations/blackchocobo_ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1574,9 +1574,14 @@ trigger showing that tutorial</source>
<message>
<source>Change Widget Style
Fusion is recommended Other themes may not obey the color palette or contain graphical issues.</source>
<translation type="unfinished">ウィジェットのスタイルを変更
<translation type="obsolete">ウィジェットのスタイルを変更
Fusion をお勧めします。他のテーマは、カラー パレットに従わないか、グラフィックの問題を含んでいる可能性があります。</translation>
</message>
<message>
<source>Fusion is the recommended theme
Other themes may contain graphical issues.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PartyTab</name>
Expand Down
7 changes: 6 additions & 1 deletion lang/bchoco_pl.ts → translations/blackchocobo_pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1578,9 +1578,14 @@ trigger showing that tutorial</source>
<message>
<source>Change Widget Style
Fusion is recommended Other themes may not obey the color palette or contain graphical issues.</source>
<translation type="unfinished">Zmień styl widżetu
<translation type="obsolete">Zmień styl widżetu
Zalecane jest Fusion Inne motywy mogą nie być zgodne z paletą kolorów lub zawierać problemy graficzne.</translation>
</message>
<message>
<source>Fusion is the recommended theme
Other themes may contain graphical issues.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PartyTab</name>
Expand Down
7 changes: 6 additions & 1 deletion lang/bchoco_re.ts → translations/blackchocobo_re.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1580,9 +1580,14 @@ trigger showing that tutorial</translation>
<message>
<source>Change Widget Style
Fusion is recommended Other themes may not obey the color palette or contain graphical issues.</source>
<translation>Change Widget Style
<translation type="vanished">Change Widget Style
Fusion is recommended Other themes may not obey the color palette or contain graphical issues.</translation>
</message>
<message>
<source>Fusion is the recommended theme
Other themes may contain graphical issues.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PartyTab</name>
Expand Down

0 comments on commit 7ac0a18

Please sign in to comment.