Initial commit
This commit is contained in:
3
examples/Demo/localization.csv
Normal file
3
examples/Demo/localization.csv
Normal 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 {} é {}!
|
||||
|
34
examples/Demo/main.cpp
Normal file
34
examples/Demo/main.cpp
Normal 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
7
examples/Demo/xmake.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
target("NzLocalization-demo")
|
||||
set_group("Examples")
|
||||
add_files("main.cpp")
|
||||
add_packages("nazara")
|
||||
add_deps("NazaraLocalization")
|
||||
set_rundir(".")
|
||||
Reference in New Issue
Block a user