Skip to content

Latest commit

 

History

History
62 lines (50 loc) · 3.23 KB

File metadata and controls

62 lines (50 loc) · 3.23 KB

Localisation

Two languages ship in locales/: English (en.lua) and German (de.lua). They use qb-core's Locale helper, which the manifest pulls in via @qb-core/shared/locale.lua. Both files are shared scripts, so Lang:t works on the client and on the server.

Selecting a language

There is no config key for this. The language is picked from qb-core's standard convar:

setr qb_locale "de"

de.lua only builds its Lang object when that convar is exactly "de". Any other value, including the default "en", leaves English in place.

Keys

All four keys live under info. Both files define all four, so there are no keys present in one language and missing in the other.

Key Placeholders English German Used at
info.cancel Canceled... Abgebrochen... Not referenced anywhere in the resource
info.got_items %{amount}, %{label} You recieved %{amount}x %{label} Du hast %{amount}x %{label} erhalten server/server.lua — success notification, both the batched and the no-materials branch
info.missing_items You are missing something! Dir fehlt etwas! client/client.lua and server/server.lua — material check failed
info.missing_role You cant do that! Das kannst du nicht tun! client/client.lua — job/gang check failed
info.inventory_full missing missing server/server.lua — the swap would exceed the weight limit

Differences and rough edges

  • info.inventory_full is used but not defined. server/server.lua calls Lang:t("info.inventory_full") when the result would not fit, but neither locale file has the key. With warnOnMissing = true the player sees the raw key text instead of a message.
  • info.missing_items ignores the variable it is given. Both call sites pass {item = QBCore.Shared.Items[reqItem].label}, so the label of the first missing material is available, but neither translation contains %{item}. Adding it to the strings — You are missing %{item} — would name the item without any code change.
  • info.cancel is dead. The progressbar's cancel callback stops the animation and unloads the dictionary without notifying the player.
  • German has no fallback. de.lua passes fallbackLang = Lang, but locales/*.lua is expanded alphabetically, so de.lua runs first and Lang is still nil at that point. en.lua then does Lang = Lang or ..., which leaves the German object in place. Since German defines every key this has no visible effect today, but a key added to en.lua alone would not fall through to a German session.
  • Typo in English. en.lua has You recieved rather than You received.
  • Spot labels are not localised. label, blip.label and processingDesc are written directly into the spot files, and the shipped examples are German. Change them in shared/*.lua, not here.

Adding a language

Copy de.lua, translate the strings, and change the convar check at the bottom to your language code. Bear the ordering note above in mind: a file that sorts after en.lua will find Lang already set to English and can use it as a real fallback, while one that sorts before it cannot.