Initial commit

This commit is contained in:
SweetId
2023-10-20 20:17:31 -04:00
commit 2fd0d0034e
13 changed files with 694 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
;fr-FR;en-US;pt-BR
LOC_HELLO_WORLD;Bonjour le monde!;Hello World!;Olá Mundo!
LOC_TEXT_ARG;{1:.2f} est la valeur de {0}!;{pi} is the value of {}!;O valor de {} é {}!
1 fr-FR en-US pt-BR
2 LOC_HELLO_WORLD Bonjour le monde! Hello World! Olá Mundo!
3 LOC_TEXT_ARG {1:.2f} est la valeur de {0}! {pi} is the value of {}! O valor de {} é {}!

34
examples/Demo/main.cpp Normal file
View File

@@ -0,0 +1,34 @@
#include <Nazara/Core/Application.hpp>
#include <NazaraLocalization/Localization.hpp>
#include <NazaraLocalization/LocalizedText.hpp>
#include <iostream>
int main(int argc, char* argv[])
{
NazaraUnused(argc);
NazaraUnused(argv);
Nz::Application<Nz::Localization> nazara;
Nz::LocalizedText helloWorld("LOC_HELLO_WORLD");
Nz::LocalizedText textWithArguments = Nz::LocalizedText("LOC_TEXT_ARG").Arg("PI").Arg("pi", Nz::Pi<float>);
// Works with printf as if you were printing a string
// There is no localization data loaded so it will just print the key
printf("%s\n%s\n", helloWorld.c_str(), textWithArguments.c_str());
// We load the CSV containing our data
Nz::Localization::Instance()->LoadLocalizationFile("localization.csv");
Nz::Localization::Instance()->SetLocale("fr-FR");
std::cout << helloWorld << std::endl << textWithArguments << std::endl;
Nz::Localization::Instance()->SetLocale("en-US");
std::cout << helloWorld << std::endl << textWithArguments << std::endl;
Nz::Localization::Instance()->SetLocale("pt-BR");
std::cout << helloWorld << std::endl << textWithArguments << std::endl;
return 0;
}

7
examples/Demo/xmake.lua Normal file
View File

@@ -0,0 +1,7 @@
target("NzLocalization-demo")
set_group("Examples")
add_files("main.cpp")
add_packages("nazara")
add_deps("NazaraLocalization")
set_rundir(".")

9
examples/xmake.lua Normal file
View File

@@ -0,0 +1,9 @@
option("examples")
set_default(false)
set_showmenu(true)
set_description("Build examples")
option_end()
if has_config("examples") then
includes("*/xmake.lua")
end