Language and translation
Translating WidgetCore — the bundled language files, the load order, every translatable string, building a new translation with the POT file, and RTL/LTR handling.
The plugin ships complete Persian and English translations and a POT template for any other language. All interface texts come from these files — nothing is hardcoded in the output.
Language files
| File | Language | Status |
|---|---|---|
languages/widgetcore-fa_IR.mo / .po | Persian | Complete, bundled |
languages/widgetcore-en_US.mo / .po | English | Complete, bundled |
languages/widgetcore.pot | Template | For building a new translation |
Translations are loaded on init at priority 1:
load_plugin_textdomain( 'widgetcore', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
Load order
WordPress resolves the current locale with determine_locale() and then looks for the .mo file in this order:
| Priority | Path | Notes |
|---|---|---|
| 1 | wp-content/languages/plugins/widgetcore-{locale}.mo | The global directory — your file wins here |
| 2 | wp-content/plugins/widgetcore/languages/widgetcore-{locale}.mo | The bundled translation |
Strings that get translated
| Area | Examples |
|---|---|
| Widget titles and descriptions | “FAQ”, “Live Search”, the category name |
| Control labels | “Results display mode”, “Items per page”, “Query ID” |
| Control descriptions and help text | The notes under each control |
| Default field values | The placeholder text, “All text” |
| Front-end messages | “No results found.”, “Error fetching results.”, “N results” |
| Pagination labels | “Previous”, “Next”, “Page”, “of”, “Load more” |
| Shortcode defaults | “View more posts”, “There are no more posts.” |
| Admin notices | The updater messages |
| Schema-related labels | Only labels; question and answer content come from your data |
The strings that reach the browser are passed through the inline window.WGCRSearch.i18n object, so the client-side messages are translated too:
window.WGCRSearch.i18n = {
noResults: 'No results found.',
found: 'results',
error: 'Error fetching results.',
prev: 'Previous',
next: 'Next',
page: 'Page',
pageOf: 'of'
};
Building a translation for a new language
Copy the template
Copy
languages/widgetcore.pottowp-content/languages/plugins/widgetcore-de_DE.po.Translate with an editor
Poedit, Loco Translate or any PO editor; keep the
msgidvalues untouched.Watch the placeholders
Strings containing
%sor%dmust keep them, in an order that works in your language.Compile the .mo
Your editor does this automatically; the
.momust sit next to the.po.Set the site language
“Settings → General → Site Language”, or a per-user language in your profile.
Verify
Check the widget panel labels, the front-end messages and the pagination text.
| Rule | Why |
|---|---|
Keep placeholders (%s, %d, %1$s) | They are filled at runtime; a missing one breaks the string |
| Do not translate code identifiers | wgcr-search, modal, page are values, not words |
| Keep the length reasonable | Long labels overflow the Elementor panel and the results header |
| Use the same term consistently | “Result” versus “Item” confuses visitors |
Right-to-left and left-to-right
The plugin does not switch direction itself; it follows the document direction:
| Direction | Source | Effect on the widgets |
|---|---|---|
| RTL | <html dir="rtl"> from the theme or the locale | Icons, panel alignment and pagination flip automatically |
| LTR | <html dir="ltr"> | The same stylesheet, mirrored by logical properties |
Because the CSS uses logical properties (inset-inline-start, margin-inline, border-inline-start, text-align: start), there is a single stylesheet for both directions and no rtl.css file to maintain.
Translating your own content
The plugin translates its interface, not your content:
| What | Translated by |
|---|---|
| Widget labels and messages | The plugin's .mo files |
| Question and answer text | You, in the Elementor editor |
| Result titles and excerpts | The posts themselves |
| The placeholder you typed | Your own text (a per-language widget if you need several) |
On a multilingual site, place one widget per language and point its Source at the post type used by that language; the interface texts then follow the active locale automatically.