Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f3a72e3
First batch of changes for i18n XML
EmmmaTech Mar 26, 2021
1092ecc
Added internal translations to source code
EmmmaTech Mar 26, 2021
14eb33b
Application - Added opt-out for i18n
EmmmaTech Mar 26, 2021
5d8e987
Added copyright
EmmmaTech Mar 26, 2021
bc9eb7f
Added some Info printing about opt-out of i18n
EmmmaTech Mar 26, 2021
f6b14f7
Merge from upstream repo
EmmmaTech Mar 26, 2021
81ad626
clang-format
EmmmaTech Mar 26, 2021
fc52c7e
Assets - New BRLS_ASSET function
EmmmaTech Mar 27, 2021
a37332c
i18n - Changed error messages
EmmmaTech Mar 27, 2021
ee79781
i18n - Starting to reimplement the i18n linter
EmmmaTech Mar 27, 2021
a1b33fa
i18n - i18nChecker function can now check valid folders
EmmmaTech Mar 27, 2021
2f0cc29
GLFW Platform - Added check if the locale can be used
EmmmaTech Mar 28, 2021
3d3640c
i18nChecker - Added warning for no default locale folder
EmmmaTech Mar 29, 2021
62e4211
Fixed build on Switch
EmmmaTech Mar 30, 2021
a04bf91
i18n - Changed how internal translations are found
EmmmaTech Mar 30, 2021
6b96d5f
i18n - Fixed mistake with if statements
EmmmaTech Mar 30, 2021
465b627
Added F14FastMap from folly library
EmmmaTech Mar 31, 2021
b03882a
Folly - Deleted unnecessary files
EmmmaTech Mar 31, 2021
9e804b8
Folly - Removed tests
EmmmaTech Apr 1, 2021
04b6b37
Removed folly (only for now)
EmmmaTech Apr 2, 2021
82fe299
git subrepo clone https://github.com/facebook/folly.git library/lib/e…
EmmmaTech Apr 2, 2021
91d4abc
Merge remote-tracking branch 'upstream/main' into i18n-xml
EmmmaTech Apr 5, 2021
5aff5f2
Updated demo.xml for merge
EmmmaTech Apr 5, 2021
a896498
Removal of Folly
EmmmaTech Nov 7, 2021
04feeef
Added script to convert i18n json to xml
EmmmaTech Nov 7, 2021
dc04576
Fixed bug where locale wouldn't be changed if i18n is disabled
EmmmaTech Nov 7, 2021
bdcad36
Added pretty-printing to i18n json to xml script
EmmmaTech Dec 15, 2021
9e1b6fc
Merge branch 'natinusala:main' into i18n-xml
EmmmaTech Dec 18, 2021
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
13 changes: 13 additions & 0 deletions library/include/borealis/core/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ typedef std::function<View*(void)> XMLViewCreator;
class Application
{
public:
/**
* Sets if the borealis application should use i18n or not.
* If called, you must call it before init().
* Is automatically set to true.
*/
static void usei18n(bool val);

/**
* Returns if this application is using i18n or not.
*/
static bool getUsingi18n();

/**
* Inits the borealis application.
* Returns true if it succeeded, false otherwise.
Expand Down Expand Up @@ -191,6 +203,7 @@ class Application
static std::string getLocale();

private:
inline static bool usingi18n = true;
inline static bool inited = false;
inline static bool quitRequested = false;

Expand Down
60 changes: 37 additions & 23 deletions library/include/borealis/core/assets.hpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
/*
Copyright 2019-2021 natinusala
Copyright 2019 p-sam

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#pragma once

#ifndef BRLS_RESOURCES
#error BRLS_RESOURCES define missing
#endif
#define BRLS_ASSET(_str) BRLS_RESOURCES _str
/*
Copyright 2019-2021 natinusala
Copyright 2019 p-sam
Copyright 2021 EmreTech

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#pragma once

#include <filesystem>
#include <string>

#ifndef BRLS_RESOURCES
#error BRLS_RESOURCES define missing
#endif

namespace brls
{
inline static std::string BRLS_ASSET(std::string _str)
{
_str = std::string(BRLS_RESOURCES) + _str;
std::filesystem::path tmp_out_path { _str };
tmp_out_path.make_preferred();
return tmp_out_path.string();
}
} // namespace brls
35 changes: 33 additions & 2 deletions library/include/borealis/core/i18n.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright 2020-2021 natinusala
Copyright 2021 EmreTech

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -20,6 +21,7 @@

#include <borealis/core/logger.hpp>
#include <string>
#include <vector>

namespace brls
{
Expand All @@ -45,11 +47,33 @@ const std::string LOCALE_ES_419 = "es-419";

const std::string LOCALE_DEFAULT = LOCALE_EN_US;

const std::vector<std::string> LOCALE_LIST = { // Vector to compare all compatiable locales with a value to see if it's valid
LOCALE_JA, LOCALE_EN_US, LOCALE_EN_GB, LOCALE_FR, LOCALE_FR_CA,
LOCALE_DE, LOCALE_IT, LOCALE_ES, LOCALE_ZH_CN, LOCALE_ZH_HANS, LOCALE_ZH_HANT, LOCALE_ZH_TW,
LOCALE_Ko, LOCALE_NL, LOCALE_PT, LOCALE_PT_BR, LOCALE_RU, LOCALE_ES_419
};

const char pathSeperator = // To check if a directory in the i18n folder is valid
#ifdef _WIN32
'\\';
#else
'/';
#endif

namespace internal
{
std::string getRawStr(std::string stringName);
std::string getRawStr(std::string stringName, bool internal = false);
} // namespace internal

/**
* Checks the i18n folder for stray directories, files, and
* XML files (ones that aren't i18n XML Files). Returns a vector containing
* all the warnings.
*/
void i18nChecker();

void loadInternal();

/**
* Returns the translation for the given string,
* after injecting format parameters (if any)
Expand All @@ -71,7 +95,7 @@ std::string getStr(std::string stringName, Args&&... args)
}

/**
* Loads all translations of the current system locale + default locale
* Loads all translations of the current system locale + default locale + internal translations
* Must be called before trying to get a translation!
*/
void loadTranslations();
Expand All @@ -84,5 +108,12 @@ inline namespace literals
* Shortcut to brls::getStr(stringName)
*/
std::string operator"" _i18n(const char* str, size_t len);

/**
* Returns the internal translation for the given string, without
* injecting any parameters
* Shortcut to brls::internal::getRawStr(stringName, true)
*/
std::string operator"" _internal(const char* str, size_t len);
} // namespace literals
} // namespace brls
Loading