WordPress multiple text domain - wordpress

I am working on a wordpress theme which is based on buildpress and it has its own languages/en_US.po translation file. I would like to add my own custom translations, seperated from the main translation file. so I've added some _e('My string', 'my-domain') and placed languages/my-domain_en_US.po but how can I make Poedit scan only my text domain since i'm scanning the theme and getting all the buildpress's strings. any ideas?

Related

Translatable strings from child theme not included in translation files

So I think that I have all the configuration for translation set, but my translatable strings are not loaded to .po or .pot.
In functions.php:
function opportune_child_setup() {
load_child_theme_textdomain( 'opportune', get_stylesheet_directory() . '/languages' );
}
add_action( 'after_setup_theme', 'opportune_child_setup' );
In style.css:
/*
[...]
Text Domain: opportune
*/
Translatable string (example):
<label for="custom_field"><?php _e( "Company Tax ID", 'opportune' ) ?></label>
Translation files directory:
themes/opportune-child/languages/opportune.pot
themes/opportune-child/languages/pt_PT.mo
themes/opportune-child/languages/pt_PT.po
The .po and .mo files were created with Poedit based on opportune.pot in the parent theme (which is located in equivalent directory:)
themes/opportune/languages/opportune.pot
I've even hardcoded in my wp-config.php (although already set in WP Admin):
define('WP_LANG', 'pt_PT');
What I do to see if the string has been loaded to either .po or .pot is: I go to a page with translatable strings, make hard refresh (deleting cache), download .po and .pot and then search for the string. None of the strings have ever been loaded.
I've used Loco Translate plugin, I think with the right configurations, and still no result.
What am I missing? Thank you so much!
Firstly, child themes should not use the same text domain as the parent theme.
If you're only using strings from the parent theme, then just translate the parent. But if you're adding new strings into your own PHP files, then use a separate text domain.
So if "Company Tax ID" is a string you've added and it isn't in the parent, ensure it's in a text domain matching the child theme folder, i.e. "opportune-child".
Secondly, strings aren't automatically "loaded into po files" as you say. You create your .pot file by extracting strings from your PHP files. Then you base your .po files from that. Read about WordPress internationalization to understand this process.
Don't create files "based on opportune.pot" because the parent theme is a separate entity. You only need to extract and load strings you've defined for your child. Let the parent take care of itself.
There is a guide for translating child themes here:
https://localise.biz/wordpress/plugin/child-themes
Full disclosure: I am the author.

Translate Multi Lingue Header Top and Header Main

How can I translate the header-main and the header-top of a page? Link: novosite.iqnus.com.br
Maybe there is some hook to add in the functions.php file.
Thanks.
0) Read the translation docs: https://codex.wordpress.org/I18n_for_WordPress_Developers
1) Make sure the strings you want to translate are recognized in your Themes' gettext files - recompile and translate them accordingly and make sure the correct language files are available in the languages directory of your Theme
2) Every dynamic content can be translated by using Plugins like WPML or qTranslate
Try This plugin it's useful for Translate Multi language Header Top and Header Main
https://wordpress.org/plugins/gtranslate/screenshots/
You can put short code header.php where you show.

Text domain issue on ThemeCheck

I am running my theme through ThemeCheck ( https://wordpress.org/plugins/theme-check/ )
One of the required fixes states:
REQUIRED: This theme text domain does not match the theme's slug. The text domain used: This theme's correct slug and text-domain is my-theme-name.
This is not a multi-language theme and I have removed all the translation from the theme, I have looked at all __() statements and _e and I believe I have successfully removed everything required for translation.
The error message should have a value after 'The text domain used: ' but it is just displaying blank too, which maybe means the issue is an empty '' in my code...?
The folder for the theme is correct and is my-theme-name
How do I find/fix this...?
The theme review standards require the following:
All theme text strings are to be translatable.
Include a text domain in style.css
You're receiving a warning because you're not following this requirement, and your text domain is an empty string.
Theme check plugin required __() function with your text domain.
If plugin can`t find __('string','my-theme-name') in theme files, he return error
"REQUIRED: This theme text domain does not match the theme's slug"

Translation for wordpress theme "Tarski"

I'm using the Tarski theme for a wordpress blog.
I want the blog to be french.
I looked at this page http://tarskitheme.com/help/localisation/, but I can't catch up how to use the .POT file to translate it in french.
I downloaded the file and opened it with geany, made all the translation, ex:
msgid "Search Results"
msgstr "Résultats de recherche
But then can someone explain to me what to do with this file?
I suppose I have to rename it to tarski_3.0-fr_FR.pot, but then where do I put it? Do I have to "compile" it somehow?
Thank you all.
EDIT
It seems that I must ask a question here to find a answer by myself, I just find that I must generate .mo file from the .POT
http://en.wikipedia.org/wiki/GNU_gettext#Translating
But I'm still don't know where to put this file... still searching.
You simply drop the .mo file in the root directory of your theme, and load the text domain. In your case, this last step is already done: the theme already loads its text domains (line 78 in functions.php, the function is load_theme_textdomain).
If you'd like a GUI for editing your translation and generating the .mo, try Poedit.

Drupal: Translation template extractor works but the string cannot be found

I'm using Translation template extractor to extract transable strings I've added to my page.tpl.php page in my zen theme files.
I've correctly exporeted zen.pot file and overwritten the previous one. The string 'random text' contained in the t('random text') function in the template is correctly added to the file.
I've refreshed cache, refreshed the tab and run cron again.
However when I search for it in the translation interface I cannot find it and therefore I cannot translate it.
thanks
The solution was to switch the language of the page containing the string at least once to save the string.
Export a .po-file, edit it with (e.g with Poedit) save the file and import it into Drupal.

Resources