Prepare for translations
This commit is contained in:
parent
29e03d62c8
commit
6dea2839b5
@ -1,27 +1,34 @@
|
||||
import os
|
||||
import khalyomede.i18n { Translations }
|
||||
|
||||
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}
|
||||
for mut arg in args {
|
||||
arg = false
|
||||
}
|
||||
for i := 0; i < os.args.len; i++ {
|
||||
if i == 0 {i++}
|
||||
match os.args[i] {
|
||||
for arg in os.args {
|
||||
match arg {
|
||||
"-i", "--icons" { args[0] = true }
|
||||
"-t", "--tooltip" { args[1] = true }
|
||||
"-a", "--all" { args[2] = true }
|
||||
"-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>
|
||||
\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")
|
||||
println(textbundle.get("helptext", { "cmd": os.args[0] }))
|
||||
exit(0)
|
||||
}
|
||||
else {
|
||||
println("Unknown argument: ${os.args[i]}")
|
||||
} else {
|
||||
if arg == os.args[0] {} else {
|
||||
println("Unknown argument: ${}")
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !args[2] {
|
||||
categorymode(args)
|
||||
} else {
|
||||
@ -169,3 +176,10 @@ fn optbuildtooltip(data []string, tooltip bool) string {
|
||||
if !tooltip { return '' }
|
||||
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