Skip to content

Localization

Expand your reach to international markets with ease. VBA Padlock features a robust JSON-based localization system that allows you to translate every runtime interaction — from activation dialogs to error messages — into any language.


Translating your application follows a straightforward logic: copy, translate, and embed.

VBA Padlock projects start with a default English file (locale_en-US.json).

  1. Copy the default file in your project folder.
  2. Rename it using the target locale code (e.g., locale_fr-FR.json).
  3. Translate the values in the JSON file.

Locale files use a flat key-value structure. Here is a simplified example for a French translation:

{
"locale": "fr-FR",
"strings": {
"common": {
"close": "Fermer",
"activate": "Activer"
},
"trial": {
"dialogTitle": "Version d'évaluation",
"dayRemaining_one": "1 jour restant",
"dayRemaining_other": "%d jours restants"
}
}
}

To maintain dynamic logic, you must preserve placeholders:

  • %s: String placeholder (e.g., "Script: %s")
  • %d: Number placeholder (e.g., "%d days")
  • _one / _other: Suffixes used for automatic pluralization based on a count.

Inside your compiled scripts, you can access the localization engine directly to display custom messages in the user’s language.

Get Basic String

' Get "activate" label
Dim label
label = L("common.activate")

Formatted String

' "14 days remaining"
Dim msg
msg = LFmt("trial.dayRemaining", 14)

Plural Forms

' Handles _one/_other automatically
Dim msg
msg = LPlural("trial.dayRemaining", count)

Runtime Loading

' Switch language on the fly
LoadLocale(jsonContent)

  1. Keep Keys Intact: Never modify the keys (left side); only translate the values (right side).
  2. Preserve Space & Case: Ensure that spaces around placeholders and the casing of labels match your UI design.
  3. Internal vs External: Use the embedded locale for the primary language, and use LoadLocale in your VBA code if you want to support users switching languages dynamically.