Prepare for translations
This commit is contained in:
parent
29e03d62c8
commit
6dea2839b5
@ -1,24 +1,31 @@
|
|||||||
import os
|
import os
|
||||||
|
import khalyomede.i18n { Translations }
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
textbundle := Translations{
|
||||||
|
default_lang: "en_US",
|
||||||
|
translations: {
|
||||||
|
"helptext": {
|
||||||
|
"en_US": "\nUsage:\n :cmd [-h] [-t] [-i] [-a]\n\nGenerates Applications menu for Joe's Window Manager.\n\nUsage in .jwmrc:\n<Dynamic label=\"Applications\" icon=\"view-list\">\n\texec: :cmd \n</Dynamic>\nOptions:\n -h, --help\tShow this text.\n -i, --icons\tAlso generate icons.\n -t, --tooltip\tAlso generate tooltips.\n -a, --all\tDo not generate categories: list all applications.\n\nv1.0"
|
||||||
|
}}}
|
||||||
|
lang := detectlang()
|
||||||
mut args := []bool{len: 3}
|
mut args := []bool{len: 3}
|
||||||
for mut arg in args {
|
for mut arg in args {
|
||||||
arg = false
|
arg = false
|
||||||
}
|
}
|
||||||
for i := 0; i < os.args.len; i++ {
|
for arg in os.args {
|
||||||
if i == 0 {i++}
|
match arg {
|
||||||
match os.args[i] {
|
|
||||||
"-i", "--icons" { args[0] = true }
|
"-i", "--icons" { args[0] = true }
|
||||||
"-t", "--tooltip" { args[1] = true }
|
"-t", "--tooltip" { args[1] = true }
|
||||||
"-a", "--all" { args[2] = true }
|
"-a", "--all" { args[2] = true }
|
||||||
"-h", "--help" {
|
"-h", "--help" {
|
||||||
println("\nUsage:\n ${os.args[0]} [-htia]\n\nGenerates Applications menu for Joe's Window Manager.\n\nUsage in .jwmrc:\n<Dynamic label=\"Applications\" icon=\"view-list\">\n\texec: ${os.args[0]}\n</Dynamic>
|
println(textbundle.get("helptext", { "cmd": os.args[0] }))
|
||||||
\nOptions:\n -h, --help\tShow this text.\n -i, --icons\tAlso generate icons.\n -t, --tooltip\tAlso generate tooltips.\n -a, --all\tDo not generate categories: list all applications.\n\nv1.0")
|
|
||||||
exit(0)
|
exit(0)
|
||||||
}
|
} else {
|
||||||
else {
|
if arg == os.args[0] {} else {
|
||||||
println("Unknown argument: ${os.args[i]}")
|
println("Unknown argument: ${}")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,3 +176,10 @@ fn optbuildtooltip(data []string, tooltip bool) string {
|
|||||||
if !tooltip { return '' }
|
if !tooltip { return '' }
|
||||||
return ('tooltip="${strfinder(data, 4)}"')
|
return ('tooltip="${strfinder(data, 4)}"')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn detectlang() string {
|
||||||
|
for item in (os.read_file('/etc/locale.conf') or { panic(err) }).split_into_lines() {
|
||||||
|
if item.contains('LANG=') { return item.substr(5, 10) }
|
||||||
|
}
|
||||||
|
return 'en_US'
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user