-
Notifications
You must be signed in to change notification settings - Fork 28
Translation
Xueping edited this page Jun 5, 2020
·
5 revisions
Put language items into resource files which are created in different directories named by the language id. See the example.
hello-world=Hello, world
title = %s Demo
email = Email address
password = Password
submit = Submit
I18n i18n = new I18n();
i18n.loadLangResources("./resources/translations");
i18n.defaultLocale = "en-us";
writeln(i18n.trans("hello-world")); // Print: Hello, world
writeln(i18n.trans("title", "Hunt Framework")); // Print: Hunt Framework Demo
writeln(i18n.transWithLocale("zh-cn", "hello-world")); // Print: 你好,世界
setLocale("zh-cn");
writeln(trans("email.title")); // Print: 标题
<title>{{trans("title",app.name)}}</title>
See the demo.