How do I change wordpress texts - wordpress

I'm pretty newbie with wordpress.
I already created my website based on template. I did couple changes on ".po" file, like:
#: wp-login.php:875 wp-login.php:950 wp-login.php:1010 wp-login.php:1112
#: wp-includes/general-template.php:324
msgid "Log in"
msgstr "Log into your awesome account"
...
#: wp-login.php:1347 wp-login.php:1391 wp-includes/general-template.php:466
msgid "Log In"
msgstr "Another Log In text"
None of them were changed. Why it happened?

.po files are for translations to other languages, not to change what is displayed by your templates.
To change texts that are part of template files, you have to change the according php files in the theme folder. But that's not a good idea, since next time the theme is updated, these changed files will be replaced by the new files and your changes will be lost.
So to avoid that, it's best to use a child theme and only include the files (as copies from the parent theme) where you want to make changes.
More on child themes here: https://developer.wordpress.org/themes/advanced-topics/child-themes/

Related

Whitelabel WordPress Theme

How do I change a WordPress Theme name and keep it changed after an update? I have tried renaming the wp-content/themes/ folder, and the name inside the style.css file as well. However, the theme goes back to its original name after the update.
Perhaps there is a plugin that automatically overwrites the theme name and renames its folder to make it white label?
Steps that I have already done:
wp-content/themes/<renamed theme> - Changed theme name
Changed name inside theme's style.css file
Anything I can do to make the theme name automatically renamed even after the theme's automatic update (have to keep it due to security).
Change the name in the /themes/[renamed theme]/style.css
The line > Theme Name: [change it here]
If you update a theme via the WordPress admin it will overwrite all of its content. If you don't want it to update, try also changing the version to something really high in the style.css.
Example:
Version: 99.99
If you still want the renamed theme to update automatically it will always update all files. This can't be avoided.
Why not just use a child theme instead? https://developer.wordpress.org/themes/advanced-topics/child-themes/

Wordpress POT file ignored

I generated pot file for my theme with wp-cli.
wp i18n make-pot wp-content/themes/my-theme/
Then I copied it and change name to pl_PL.pot which is my native language, but even when I change value in this file on my website i still see English version instead of Polish.
#: tools/customizer.php:5
msgid "Theme options"
msgstr "Opcje motywu"
I use __() and _e() function. I added Text Domain: my-theme to style.css and set polish language in wordpress setting but still not work.

How to change Woocommerce system text

I would like to know where the file with Woocommerce system messages and text (for ex. - Add to cart, Product Description etc...)?
I think woocommerce should have a language file, where I can change whatever I want, right?
Thanks
Yes, woocommerce, theme and core file provide .po .mo files, that you can modify with poedit (for example).
They are located in the folder, wp-content/plugins/woocommerce/languages/
Every translatable strings can be spot in php files with the functions __('Add to cart', 'woocommerce'); or _e('Add to cart', 'woocommerce');
You can edit them or create your own language file with poedit. New language must have the language "slug" at its end, i.e: woocommerce-fr_FR.mo (po files remains woocommerce.po).
When editing or creating these files, you need to put them in the folder wp-content/languages/plugins/woocommerce/. If you leave them in the main woocommerce languages folder they will be delete and replace by new one when you update the plugin.
You will find better explanation in the internationalization handbook here
if you want override the language of a plugin or theme, put it in
/wp-content/languages/plugins/ or /wp-content/languages/themes/

How to Unset title ('Search results') on Search results page?

How to Unset title ('Search results') on Search results page?
I'm still noobish and I was trying this:
function mymodulename_preprocess_search_result(&$variables)
{
$variables['title'] = NULL;
}
You can not change it with a preprocess since the sentence is just a printed string in the template not a variable. So you have to alter the template.
In the templates folder of your theme, duplicate the template from /root directory of your site/modules/search/search-results.tpl.php.
And edit this file as you wish.
The theme template file will be automatically called instead of the one in the core.
You just need to change output rendering. Easy way to do this is to change search core module template file.
Go on:
\modules\search\search-results.tpl.php
In that file just delete output string or replace it with empty one. Find next line in code:
<h2><?php print t('Search results');?></h2>
You can delete whole row there or you can change it to:
<h2><?php print t('');?></h2>
NOTE:
When you change core modules you should pay attention you don't overwrite it with release which comes in new Drupal core (in case you want to upgrade your Drupal core).
If you not sure you will replace this file in future (during possible module or even entire Drupal core update) you might consider copy this file in your theme template folder. After putting that file in your theme template files folder you just need to clear the cache and that file will be called instead of one in core module.
#Laurent Thank you for your update.
Hope this helps.

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.

Resources