mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-02 04:38:16 +00:00
[i18n] QT Linguist TS reader.
This commit is contained in:
@@ -4,9 +4,9 @@ import "core:mem"
|
||||
import "core:fmt"
|
||||
import "core:i18n"
|
||||
|
||||
LOC :: i18n.get
|
||||
_T :: i18n.get
|
||||
|
||||
_main :: proc() {
|
||||
mo :: proc() {
|
||||
using fmt
|
||||
|
||||
err: i18n.Error
|
||||
@@ -23,27 +23,60 @@ _main :: proc() {
|
||||
These are in the .MO catalog.
|
||||
*/
|
||||
println("-----")
|
||||
println(LOC(""))
|
||||
println(_T(""))
|
||||
println("-----")
|
||||
println(LOC("There are 69,105 leaves here."))
|
||||
println(_T("There are 69,105 leaves here."))
|
||||
println("-----")
|
||||
println(LOC("Hellope, World!"))
|
||||
println(_T("Hellope, World!"))
|
||||
|
||||
/*
|
||||
For ease of use, pluralized lookup can use both singular and plural form as key for the same translation.
|
||||
*/
|
||||
println("-----")
|
||||
printf(LOC("There is %d leaf.\n", 1), 1)
|
||||
printf(LOC("There is %d leaf.\n", 42), 42)
|
||||
printf(_T("There is %d leaf.\n", 1), 1)
|
||||
printf(_T("There is %d leaf.\n", 42), 42)
|
||||
|
||||
printf(LOC("There are %d leaves.\n", 1), 1)
|
||||
printf(LOC("There are %d leaves.\n", 42), 42)
|
||||
printf(_T("There are %d leaves.\n", 1), 1)
|
||||
printf(_T("There are %d leaves.\n", 42), 42)
|
||||
|
||||
/*
|
||||
This isn't.
|
||||
*/
|
||||
println("-----")
|
||||
println(LOC("Come visit us on Discord!"))
|
||||
println(_T("Come visit us on Discord!"))
|
||||
}
|
||||
|
||||
qt :: proc() {
|
||||
using fmt
|
||||
|
||||
err: i18n.Error
|
||||
|
||||
/*
|
||||
Parse QT file and set it as the active translation so we can omit `get`'s "catalog" parameter.
|
||||
*/
|
||||
i18n.ACTIVE, err = i18n.parse_qt(#load("../../../tests/core/assets/XML/nl_NL-qt-ts.ts"))
|
||||
defer i18n.destroy()
|
||||
|
||||
fmt.printf("parse_qt returned %v\n", err)
|
||||
if err != .None {
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
These are in the .TS catalog.
|
||||
*/
|
||||
println("--- Page section ---")
|
||||
println("Page:Text for translation =", _T("Page", "Text for translation"))
|
||||
println("-----")
|
||||
println("Page:Also text to translate =", _T("Page", "Also text to translate"))
|
||||
println("-----")
|
||||
println("--- installscript section ---")
|
||||
println("installscript:99 bottles of beer on the wall =", _T("installscript", "99 bottles of beer on the wall"))
|
||||
println("-----")
|
||||
println("--- apple_count section ---")
|
||||
println("apple_count:%d apple(s) =")
|
||||
println("\t 1 =", _T("apple_count", "%d apple(s)", 1))
|
||||
println("\t 42 =", _T("apple_count", "%d apple(s)", 42))
|
||||
}
|
||||
|
||||
main :: proc() {
|
||||
@@ -53,7 +86,8 @@ main :: proc() {
|
||||
mem.tracking_allocator_init(&track, context.allocator)
|
||||
context.allocator = mem.tracking_allocator(&track)
|
||||
|
||||
_main()
|
||||
// mo()
|
||||
qt()
|
||||
|
||||
if len(track.allocation_map) > 0 {
|
||||
println()
|
||||
|
||||
Reference in New Issue
Block a user