I didn’t find the right way but figured out this way:
if (get_locale() == 'fa_IR') {
parent::__construct(
'araccordion_widget',
__('افزونه وردپرس', $text_domain),
array( 'description' => __( 'توضیحات افزونه به زبان فارسی در اینجا نوشته میشود.', $text_domain ), )
);
}
else {
parent::__construct(
'araccordion_widget',
__('WordPress Widget', $text_domain),
array( 'description' => __( 'The description in English, goes here', $text_domain ), )
);
}
It works though it doesn’t seem the right way because if the widget is translated to more languages in the future, I’ve to add an elseif for it too. Otherwise the title and the desc will be still English in that new language.
Related Posts:
- How to make a WordPress plugin translation ready?
- How to provide translations for a WordPress TinyMCE plugin?
- Problems with localization
- How does gettext works for translating readme file of plugin?
- `wp_set_script_translations` with `wp.i18n` does not return translated strings in simple plugin
- Can’t we use strings defined as PHP constants if we want to translate them in a plugin?
- WordPress: After Gutenberg plugin migration to block.json the localization/ translations with PolyGlot in JavaScript does not work anymore
- use __($str) to translate strings (symfony/twig)
- Plugin Localization
- Is it possible to check is loaded language files correctly with WordPress plugin?
- Translate strings not recognised in plugin
- How to i18n text coming from the db or from an external source
- Should I always prefer esc_attr_e & esc_html_e instead of _e?
- Should shorcodes in i18n plugins be translated and if so, how?
- Widget translation on my plugin
- Plugin translations not installed but… strings are translated!
- .mo translation strings not loading in PHP scripts that handle AJAX calls
- Generate JSON files for language translation from po file without wp-cli i18n make-json
- Build a translation correcter plugin
- Translation per IP location [closed]
- Translate slug in WPMU with PO files
- Translate MCE button text/tooltip in custom plugin
- esc_html__() and __() not working within arrays
- How to prevent someone from entering strings without making it available for translation?
- Readme.txt seems to be cached but not the version
- Return Value of load_plugin_textdomain
- Translate javascript with WordPress built-in localization API for static strings
- Plugin language always shows WP site language, not profile language
- Is hint for translator compulsory while internationalizing a string containing variables?
- Translating plugin settings page – dropdown list
- Make dynamic string translatable
- Using HTML links within translatable string
- How to translate wordpress backend to another language
- Borrowing of Previously Translated Strings by Child Plugin
- Translations only load from `wp-content/languages/plugins` but not from the plugin’s languages folder
- Include external po file for 3th party plugin to theme
- HTML Elements in my WP Plugin being generated in JS. Security and Translated Text Question about this method being used
- Load custom translation in custom plugin fails
- Add language localisation to javascript alert?
- How to store in the database directly the translation?
- Translation not working for Constant strings in Plugin
- Load textdomain from global languages directory
- Plugin translation not being displayed
- Problem with Poedit [closed]
- get the queried_object of an url
- Save translation file of third party plugin in a custom plugin?
- Add self-closing shortcode button to TinyMCE in WP 4.6
- WordPress Hook for user register
- Must-use plugins autoloader: How to use get_plugins() correctly?
- Changing upload directory for plugin uploads only
- Upload file to remote storage
- How do I conditionally enqueue script for CPT single post type with plugin?
- wp_localize_script $handle
- Help adding image upload functionality to widget
- Rewrite url for existing page without flush_rewrite_rules
- Front-End Interfaces Without Shortcodes
- Is there a way to loop through a shortcode datasource to create a table?
- Execute plugin for specific user role(s) only
- How can I render shortcode so that its not cached by Caching plugins?
- load_theme_textdomain path
- Enqueue scripts in footer
- Is It Always a Best Practice to Decouple the Frontend from the Admin Area When Developing a WordPress Application?
- the_editor() function
- Including the necessary functions for a custom ajax registration form
- Why doesn’t my simple the_title filter get applied?
- WordPress clean internationalization for menus?
- JSX in WordPress Plugin Development
- W3 Total Cache JS and css Minify folder are empty
- TinyMCE editor turns white on Biographical info [closed]
- How I can use order by of the custom post title?
- How to create custom settings page for custom plugin
- Internationalizing Plugin
- Update File Once Every 30 Days
- Taxonomies within plugin invalid
- Make Database query only when option is updated
- Use npm and wp-env to make production bundle
- Looking for a better way to initiate cron job
- shortcode executed in the page editor
- Form using admin-post.php gives 404 after submission
- per blog metadata for plugin
- How to use gettext for specific user role
- Custom Post Type Object – Undefined Variables
- How does “Your comment is awaiting moderation” work?
- How to link to custom “archive like” page with custom permalink rules “dynamically”
- rewrite_rules problem
- Dynamic page generation upon purchase of a product
- How to show the posts listing on dashboard or custom page in admin panel?
- Settings API not saving
- Allowing duplicating users with same user_login and user_email
- Updating the_post content is only working with Twenty Twenty theme
- Scripts/styles not loading on cloned WP Site when logged in
- Save in my custom admin page and redirect to the saved object
- Undefined notice on unset field
- Script work on non logged in user but not work for logged in user?
- admin page passing $_POST variables to itself
- Get URL of Post You Are Editing
- Nothing happens on WordPress Update command
- Widget plugin and input file
- Is wordpress plugin development active? [closed]
- Programmatically creating posts based on external JSON feed (asynchronously)