Weblate单个组件能否处理多目录及.properties文件并实现特定目录翻译?
Weblate: Handling Multi-Directory .properties Files & Targeted Key Translations
1. Using a Single Weblate Component for Multiple Directories of .properties Files
Absolutely, you can configure one Weblate component to handle .properties files spread across multiple directories in your Git branch. Here's how to set it up:
- Use a wildcard file mask: Head to your component's Files settings and define a mask that matches all relevant files across directories. For example:
This will pick up every*/src/main/resources/i18n/*.properties.propertiesfile insidei18nfolders, regardless of their parent directory. Tweak the path to match your project's actual structure. - Ensure language code compatibility: Make sure your files follow a naming pattern Weblate can recognize (like
messages_de.propertiesfor German,messages_en.propertiesfor English). If your naming is non-standard, add a custom language mapping in the Files section under Language mapping. - Confirm repository sync: Double-check that your component's Version control settings point to the correct Git repo and branch. Once saved, Weblate will automatically pull all files that match your mask.
2. Targeting a Specific German Key in a Specific Directory
To translate only a specific key in German for files in a particular directory, combine two Weblate features for precise control:
- Narrow to your target directory first: Adjust the component's file mask to only include the directory you care about. For example, if you want to focus on files in
payment-module/i18n, use this mask:payment-module/src/main/resources/i18n/*.properties - Restrict to the specific key: In the component's Translations settings, find the Allowed keys option and enter the exact key you need to work on (e.g.,
payment.confirmation.text). Weblate will then only display this key for translation, hiding all others in the matched files. - Filter by language: Use the language selector in Weblate's translation interface to switch to German—this lets you focus solely on that language's version of the targeted key.
If you don't want to modify the component's config permanently, you can also use the built-in search bar to filter directly: search for something like key:payment.confirmation.text AND path:payment-module to instantly find the exact content you need.
内容的提问来源于stack exchange,提问作者Prometheus
相关产品推荐
相关产品推荐

