Skip to content

Commit a50f987

Browse files
committed
Foundations for multi-language support
1 parent 05fddc3 commit a50f987

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

Library/Sources/Framework/Language.cpp

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,34 @@
33
#include "../../../Includes/stdafx.hpp"
44

55
namespace CTRPluginFramework {
6+
// Define an enumeration for supported languages
67
enum Lang {
7-
ENG,
8-
FRE
8+
ENG, // English
9+
FRE // French
910
};
1011

11-
// Global to keep the current language
12-
Lang g_language = ENG;
12+
// Language class to manage the current language setting and provide translation functionality
13+
class Language {
14+
public:
15+
// Constructor to initialize the current language to English by default
16+
Language() : m_currentLanguage(ENG) {}
1317

14-
string AutoLanguage(string english, string french) {
15-
return (g_language == ENG ? english : french);
16-
}
18+
// Function to set the current language
19+
void setLanguage(Lang lang) {
20+
m_currentLanguage = lang;
21+
}
22+
23+
// Function to get the current language
24+
Lang getLanguage() const {
25+
return m_currentLanguage;
26+
}
27+
28+
// Function to automatically choose the correct translation based on the current language setting
29+
string autoLanguage(string english, string french) const {
30+
return (m_currentLanguage == ENG ? english : french);
31+
}
32+
33+
private:
34+
Lang m_currentLanguage; // Member variable to store the current language setting
35+
};
1736
}

0 commit comments

Comments
 (0)