Skip to content

Commit

Permalink
Change japanese language code JP to ISO 639's JA
Browse files Browse the repository at this point in the history
  • Loading branch information
michalrudolf authored and danopernis committed Jul 16, 2024
1 parent 3f03d21 commit 5a77ec6
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 63 deletions.
16 changes: 8 additions & 8 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,7 @@
}
},
{
"name": "mini-en-jp_debug_boot",
"name": "mini-en-ja_debug_boot",
"generator": "Ninja",
"binaryDir": "build-vscode-buddy",
"cacheVariables": {
Expand Down Expand Up @@ -2009,7 +2009,7 @@
},
"TRANSLATIONS_LIST": {
"type": "STRING",
"value": "jp"
"value": "ja"
},
"BOOTLOADER": {
"type": "STRING",
Expand Down Expand Up @@ -2046,7 +2046,7 @@
}
},
{
"name": "mini-en-jp_debug_noboot",
"name": "mini-en-ja_debug_noboot",
"generator": "Ninja",
"binaryDir": "build-vscode-buddy",
"cacheVariables": {
Expand Down Expand Up @@ -2076,7 +2076,7 @@
},
"TRANSLATIONS_LIST": {
"type": "STRING",
"value": "jp"
"value": "ja"
},
"BOOTLOADER": {
"type": "STRING",
Expand Down Expand Up @@ -2113,7 +2113,7 @@
}
},
{
"name": "mini-en-jp_release_boot",
"name": "mini-en-ja_release_boot",
"generator": "Ninja",
"binaryDir": "build-vscode-buddy",
"cacheVariables": {
Expand Down Expand Up @@ -2143,7 +2143,7 @@
},
"TRANSLATIONS_LIST": {
"type": "STRING",
"value": "jp"
"value": "ja"
},
"BOOTLOADER": {
"type": "STRING",
Expand Down Expand Up @@ -2180,7 +2180,7 @@
}
},
{
"name": "mini-en-jp_release_noboot",
"name": "mini-en-ja_release_noboot",
"generator": "Ninja",
"binaryDir": "build-vscode-buddy",
"cacheVariables": {
Expand Down Expand Up @@ -2210,7 +2210,7 @@
},
"TRANSLATIONS_LIST": {
"type": "STRING",
"value": "jp"
"value": "ja"
},
"BOOTLOADER": {
"type": "STRING",
Expand Down
2 changes: 1 addition & 1 deletion ProjectOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ set(LANGUAGES_AVAILABLE
ES
FR
IT
JP
JA
PL
)
if("${TRANSLATIONS_LIST}" STREQUAL "<default>")
Expand Down
4 changes: 2 additions & 2 deletions src/gui/fonts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include "fonts.hpp"
#include "config.h"
#include <guiconfig/guiconfig.h>
#include <option/enable_translation_jp.h>
#include <option/enable_translation_ja.h>

#ifdef USE_ST7789
#if ENABLE_TRANSLATION_JP()
#if ENABLE_TRANSLATION_JA()
#include "res/cc/font_regular_7x13_full.hpp" //Font::small
#include "res/cc/font_regular_11x18_full.hpp" //Font::normal
#include "res/cc/font_regular_9x16_full.hpp" //Font::special
Expand Down
2 changes: 1 addition & 1 deletion src/gui/res/mini_used_imgs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ flag_es_16x11.png
flag_fr_16x11.png
flag_it_16x11.png
flag_pl_16x11.png
flag_jp_16x11.png
flag_ja_16x11.png
language_white_16x16.png
ok_color_16x16.png
na_color_16x16.png
Expand Down
File renamed without changes
4 changes: 2 additions & 2 deletions src/gui/screen_menu_languages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ uint16_t MI_POLISH::LangCode() const {
}

MI_JAPANESE::MI_JAPANESE()
: MI_LangBase(label, &img::flag_jp_16x11, is_hidden_t::no) {}
: MI_LangBase(label, &img::flag_ja_16x11, is_hidden_t::no) {}

uint16_t MI_JAPANESE::LangCode() const {
return Translations::MakeLangCode("jp");
return Translations::MakeLangCode("ja");
}

MI_TEST_LANG::MI_TEST_LANG()
Expand Down
8 changes: 5 additions & 3 deletions src/gui/screen_menu_languages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#include <option/enable_translation_fr.h>
#include <option/enable_translation_it.h>
#include <option/enable_translation_pl.h>
#include <option/enable_translation_jp.h>
#include <option/enable_translation_ja.h>
#include <str_utils.hpp>
#include <img_resources.hpp>

class MI_LangBase : public IWindowMenuItem {
public:
Expand Down Expand Up @@ -142,7 +144,7 @@ using ScreenMenuLanguages__ = ScreenMenu<EFooter::Off, MI_RETURN, MI_ENGLISH,
#if ENABLE_TRANSLATION_PL()
MI_POLISH,
#endif
#if ENABLE_TRANSLATION_JP()
#if ENABLE_TRANSLATION_JA()
MI_JAPANESE,
#endif
MI_TEST_LANG>;
Expand Down Expand Up @@ -174,7 +176,7 @@ using ScreenMenuLanguagesNoReturn__ = ScreenMenu<EFooter::Off, MI_ENGLISH,
#if ENABLE_TRANSLATION_PL()
MI_POLISH,
#endif
#if ENABLE_TRANSLATION_JP()
#if ENABLE_TRANSLATION_JA()
MI_JAPANESE,
#endif
MI_TEST_LANG>;
Expand Down
File renamed without changes.
File renamed without changes.
20 changes: 10 additions & 10 deletions src/lang/translation_provider_CPUFLASH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <option/enable_translation_es.h>
#include <option/enable_translation_it.h>
#include <option/enable_translation_pl.h>
#include <option/enable_translation_jp.h>
#include <option/enable_translation_ja.h>

#if HAS_TRANSLATIONS()
#include <option/translations_in_extflash.h>
Expand Down Expand Up @@ -154,23 +154,23 @@ ProviderRegistrator plReg("pl", &pl);
} // namespace
#endif

#if ENABLE_TRANSLATION_JP()
struct StringTableJP {
#if ENABLE_TRANSLATION_JA()
struct StringTableJA {
static const uint32_t stringBegins[]; ///< this will get statically precomputed for each translation language separately
static const uint8_t utf8Raw[]; ///< a piece of memory where the null-terminated strings are situated
};

using CPUFLASHTranslationProviderJP = CPUFLASHTranslationProvider<StringTableJP>;
using CPUFLASHTranslationProviderJA = CPUFLASHTranslationProvider<StringTableJA>;

// precomputed indices and strings for the JP language
#include "stringBegins.jp.hpp"
#include "utf8Raw.jp.hpp"
// precomputed indices and strings for the JA language
#include "stringBegins.ja.hpp"
#include "utf8Raw.ja.hpp"
template <>
const CPUFLASHTranslationProviderJP::RawData CPUFLASHTranslationProviderJP::rawData;
const CPUFLASHTranslationProviderJA::RawData CPUFLASHTranslationProviderJA::rawData;

namespace {
static const CPUFLASHTranslationProviderJP jp;
ProviderRegistrator jpReg("jp", &jp);
static const CPUFLASHTranslationProviderJA ja;
ProviderRegistrator jaReg("ja", &ja);

} // namespace
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/lang/translation_provider_FILE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <option/enable_translation_fr.h>
#include <option/enable_translation_it.h>
#include <option/enable_translation_pl.h>
#include <option/enable_translation_jp.h>
#include <option/enable_translation_ja.h>

extern "C" size_t strlcpy(char *dst, const char *src, size_t dsize);

Expand Down Expand Up @@ -96,9 +96,9 @@ static const FILETranslationProvider pl("/internal/res/lang/pl.mo");
ProviderRegistrator plReg("pl", &pl);
#endif

#if ENABLE_TRANSLATION_JP()
static const FILETranslationProvider jp("/internal/res/lang/jp.mo");
ProviderRegistrator jpReg("jp", &jp);
#if ENABLE_TRANSLATION_JA()
static const FILETranslationProvider ja("/internal/res/lang/ja.mo");
ProviderRegistrator jaReg("ja", &ja);
#endif
} // namespace
#endif
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/lang/translator/option/enable_translation_ja.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#define ENABLE_TRANSLATION_JA() 1

#ifdef __cplusplus

namespace option {
inline constexpr bool enable_translation_ja = 1;
}

#endif
11 changes: 0 additions & 11 deletions tests/unit/lang/translator/option/enable_translation_jp.h

This file was deleted.

26 changes: 13 additions & 13 deletions tests/unit/lang/translator/providerCPUFLASH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ uint16_t StringTablePLTest::stringBeginsSize;
using CPUFLASHTranslationProviderPLTest = CPUFLASHTranslationProvider<StringTablePLTest>;

/*
struct StringTableJPTest {
struct StringTableJATest {
// this will get statically precomputed for each translation language separately
static uint16_t stringCount, stringBytes;
static uint16_t stringBeginsSize;
Expand All @@ -193,12 +193,12 @@ struct StringTableJPTest {
}
};
uint32_t StringTableJPTest::stringBegins[maxStringBegins], StringTableJPTest::utf8RawSize;
uint8_t StringTableJPTest::utf8Raw[maxUtf8Raw];
uint16_t StringTableJPTest::stringCount, StringTableJPTest::stringBytes;
uint16_t StringTableJPTest::stringBeginsSize;
uint32_t StringTableJATest::stringBegins[maxStringBegins], StringTableJATest::utf8RawSize;
uint8_t StringTableJATest::utf8Raw[maxUtf8Raw];
uint16_t StringTableJATest::stringCount, StringTableJATest::stringBytes;
uint16_t StringTableJATest::stringBeginsSize;
using CPUFLASHTranslationProviderJPTest = CPUFLASHTranslationProvider<StringTableJPTest>;
using CPUFLASHTranslationProviderJATest = CPUFLASHTranslationProvider<StringTableJATest>;
*/

TEST_CASE("providerCPUFLASH::StringTableAt", "[translator]") {
Expand Down Expand Up @@ -295,7 +295,7 @@ TEST_CASE("providerCPUFLASH::Translations singleton", "[translator]") {
REQUIRE(Translations::Instance().LangExists(Translations::MakeLangCode("fr")));
REQUIRE(Translations::Instance().LangExists(Translations::MakeLangCode("it")));
REQUIRE(Translations::Instance().LangExists(Translations::MakeLangCode("pl")));
// REQUIRE(Translations::Instance().LangExists(Translations::MakeLangCode("jp")));
// REQUIRE(Translations::Instance().LangExists(Translations::MakeLangCode("ja")));
}

/// This is a complex test of the whole translation mechanism
Expand All @@ -316,7 +316,7 @@ TEST_CASE("providerCPUFLASH::ComplexTest", "[translator]") {
CPUFLASHTranslationProviderFRTest providerFR;
CPUFLASHTranslationProviderITTest providerIT;
CPUFLASHTranslationProviderPLTest providerPL;
// CPUFLASHTranslationProviderPLTest providerJP;
// CPUFLASHTranslationProviderPLTest providerJA;
deque<string> rawStringKeys;
FillHashTableCPUFLASHProvider(CPUFLASHTranslationProviderBase::hash_table, "keys.txt", rawStringKeys);

Expand All @@ -328,7 +328,7 @@ TEST_CASE("providerCPUFLASH::ComplexTest", "[translator]") {
REQUIRE(LoadTranslatedStringsFile("fr.txt", &frStrings));
REQUIRE(LoadTranslatedStringsFile("it.txt", &itStrings));
REQUIRE(LoadTranslatedStringsFile("pl.txt", &plStrings));
// REQUIRE(LoadTranslatedStringsFile("jp.txt", &jpStrings));
// REQUIRE(LoadTranslatedStringsFile("ja.txt", &jaStrings));

// need to have at least the same amount of translations like the keys (normally there will be an exact number of them)
REQUIRE(rawStringKeys.size() <= csStrings.size());
Expand All @@ -337,7 +337,7 @@ TEST_CASE("providerCPUFLASH::ComplexTest", "[translator]") {
REQUIRE(rawStringKeys.size() <= frStrings.size());
REQUIRE(rawStringKeys.size() <= itStrings.size());
REQUIRE(rawStringKeys.size() <= plStrings.size());
// REQUIRE(rawStringKeys.size() <= jpStrings.size());
// REQUIRE(rawStringKeys.size() <= jaStrings.size());

// now make the string table from cs.txt
FillStringTable<StringTableCSTest>(csStrings);
Expand All @@ -346,7 +346,7 @@ TEST_CASE("providerCPUFLASH::ComplexTest", "[translator]") {
FillStringTable<StringTableFRTest>(frStrings);
FillStringTable<StringTableITTest>(itStrings);
FillStringTable<StringTablePLTest>(plStrings);
// FillStringTable<StringTableJPTest>(jpStrings);
// FillStringTable<StringTableJATest>(jaStrings);

// prepare a map for comparison
set<unichar> nonASCIICharacters;
Expand All @@ -367,7 +367,7 @@ TEST_CASE("providerCPUFLASH::ComplexTest", "[translator]") {
REQUIRE(CheckAllTheStrings(rawStringKeys, frStrings, providerFR, nonASCIICharacters, "fr"));
REQUIRE(CheckAllTheStrings(rawStringKeys, itStrings, providerIT, nonASCIICharacters, "it"));
REQUIRE(CheckAllTheStrings(rawStringKeys, plStrings, providerPL, nonASCIICharacters, "pl"));
// REQUIRE(CheckAllTheStrings(rawStringKeys, jpStrings, providerJP, nonASCIICharacters, "jp"));
// REQUIRE(CheckAllTheStrings(rawStringKeys, jaStrings, providerJA, nonASCIICharacters, "ja"));

CompareHashTables();

Expand All @@ -377,7 +377,7 @@ TEST_CASE("providerCPUFLASH::ComplexTest", "[translator]") {
CompareProviders(&providerFR, "fr");
CompareProviders(&providerIT, "it");
CompareProviders(&providerPL, "pl");
// CompareProviders(&providerJP, "jp");
// CompareProviders(&providerJA, "ja");

// Check the content of generated non-ascii-chars - to see, if we have enough font bitmaps

Expand Down
10 changes: 5 additions & 5 deletions tests/unit/lang/translator/providerFILE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TEST_CASE("providerFILE::Translations test", "[translator]") {
FILETranslationProvider providerFR("MO/fr.mo");
FILETranslationProvider providerIT("MO/it.mo");
FILETranslationProvider providerPL("MO/pl.mo");
// FILETranslationProvider providerPL("MO/jp.mo");
// FILETranslationProvider providerPL("MO/ja.mo");

// load transtaled strings
deque<string> csStrings, deStrings, esStrings, frStrings, itStrings, plStrings;
Expand All @@ -26,7 +26,7 @@ TEST_CASE("providerFILE::Translations test", "[translator]") {
REQUIRE(LoadTranslatedStringsFile("MO/fr.txt", &frStrings));
REQUIRE(LoadTranslatedStringsFile("MO/it.txt", &itStrings));
REQUIRE(LoadTranslatedStringsFile("MO/pl.txt", &plStrings));
// REQUIRE(LoadTranslatedStringsFile("MO/jp.txt", &jpStrings));
// REQUIRE(LoadTranslatedStringsFile("MO/ja.txt", &jaStrings));

// need to have at least the same amount of translations like the keys (normally there will be an exact number of them)
REQUIRE(stringKeys.size() <= csStrings.size());
Expand All @@ -35,7 +35,7 @@ TEST_CASE("providerFILE::Translations test", "[translator]") {
REQUIRE(stringKeys.size() <= frStrings.size());
REQUIRE(stringKeys.size() <= itStrings.size());
REQUIRE(stringKeys.size() <= plStrings.size());
// REQUIRE(stringKeys.size() <= jpStrings.size());
// REQUIRE(stringKeys.size() <= jaStrings.size());

set<unichar> nonASCIICharacters;
{
Expand All @@ -55,15 +55,15 @@ TEST_CASE("providerFILE::Translations test", "[translator]") {
REQUIRE(providerFR.EnsureFile());
REQUIRE(providerIT.EnsureFile());
REQUIRE(providerPL.EnsureFile());
// REQUIRE(providerJP.EnsureFile());
// REQUIRE(providerJA.EnsureFile());

REQUIRE(CheckAllTheStrings(stringKeys, csStrings, providerCS, nonASCIICharacters, "cs"));
REQUIRE(CheckAllTheStrings(stringKeys, deStrings, providerDE, nonASCIICharacters, "de"));
REQUIRE(CheckAllTheStrings(stringKeys, esStrings, providerES, nonASCIICharacters, "es"));
REQUIRE(CheckAllTheStrings(stringKeys, frStrings, providerFR, nonASCIICharacters, "fr"));
REQUIRE(CheckAllTheStrings(stringKeys, itStrings, providerIT, nonASCIICharacters, "it"));
REQUIRE(CheckAllTheStrings(stringKeys, plStrings, providerPL, nonASCIICharacters, "pl"));
// REQUIRE(CheckAllTheStrings(stringKeys, jpStrings, providerJP, nonASCIICharacters, "jp"));
// REQUIRE(CheckAllTheStrings(stringKeys, jaStrings, providerJA, nonASCIICharacters, "ja"));

CAPTURE(stringKeys.size());
}
Expand Down
6 changes: 3 additions & 3 deletions utils/presets/presets.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@
}
},
{
"name": "mini-en-jp",
"description": "Original Prusa MINI (EN & JP translation)",
"name": "mini-en-ja",
"description": "Original Prusa MINI (EN & JA translation)",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"PRINTER": "MINI",
"BOARD": "BUDDY",
"BOARD_VERSION": "1.0.0",
"DEVELOPMENT_ITEMS_ENABLED": true,
"TRANSLATIONS_LIST": "jp"
"TRANSLATIONS_LIST": "ja"
}
},
{
Expand Down

0 comments on commit 5a77ec6

Please sign in to comment.