| 1 | // gettext lookup follows libalpm's util.h domain and alpm.c initialization. |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | module engine |
| 4 | |
| 5 | #include "@VMODROOT/engine/native_locale.h" |
| 6 | |
| 7 | #flag darwin -lintl |
| 8 | #flag freebsd -lintl |
| 9 | |
| 10 | fn C.bindtextdomain(const_domain &char, const_directory &char) &char |
| 11 | fn C.dgettext(const_domain &char, const_message &char) &char |
| 12 | |
| 13 | fn initialize_locale() { |
| 14 | C.bindtextdomain(c'libalpm', c'/usr/share/locale') |
| 15 | } |
| 16 | |
| 17 | fn translated_message(message string) string { |
| 18 | result := C.dgettext(c'libalpm', unsafe { &char(message.str) }) |
| 19 | if result == unsafe { nil } { return message } |
| 20 | return unsafe { tos_clone(result) } |
| 21 | } |
| 22 | |