Text domain issue on ThemeCheck - wordpress

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"

Related

WordPress multiple text domain

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?

Buddypress template hierarchy is not being used

I am updating an installation of buddypress (1.5) to the most recent version (2.1.1). I have updated the files and am now trying to update the theme to use the template hierarchy pattern.
For this I created the following directory structure within my theme:
my-theme/
buddypress/
groups/
index-directory.php
index-directory.php contains a single die('debug') statement for testing.
If I copy this buddypress directory into the twentyfourteen directory and activate that theme, I am seeing the debug message when I'm on the group listing page. However, when I use my custom theme, the message is not showing up.
This tells me that the template hierarchy is not being applied on my theme. Why could that be?
I suspect that somehow my theme is being treated as a legacy theme, I don't understand why though. I commented out the whole functions.php to make sure it's not because of aynthing in there. The header comment in the style.css does not contain anything special either.
Any help on this?
Thanks.
The problem was my own mistake. Our theme stylesheet had a Template: bp-default in it. I didn’t notice it at first because our theme is named similarly and my mind read it as the title of our theme. If I remove it, my templates are included.
For anyone stumbling on this problem in the future, here are the reasons why the template hierarchy could be deactivated by Buddypress:
Theme compat is disabled when a theme meets one of the following criteria:
1) It declares BP support with add_theme_support( 'buddypress' )
2) It is bp-default, or a child theme of bp-default
3) A legacy template is found at members/members-loop.php. This is a
fallback check for themes that were derived from bp-default, and have
not been updated for BP 1.7+; we make the assumption that any theme in
this category will have the members-loop.php template, and so use its
presence as an indicator that theme compatibility is not required
https://buddypress.org/support/topic/default-theme-is-still-showing/

how do i change the woocommerce_sale_flash part on a multilanguage site?

I'm building a multilingual site with WP using Woocommerce.
The client asked me to change the Sale Flash text, after some research i found this code
add_filter('woocommerce_sale_flash', 'avia_change_sale_content', 10, 3);
function avia_change_sale_content($content, $post, $product){
$content = '<span class="onsale">'.__( 'Sale custom text!', 'woocommerce' ).'</span>';
return $content;
}
It works just fine, but it also changes the german and spanish text - replacing it with the english one.
I checked at the WPML strings (hoping to translate it through that system), but couldn't find it there.
Does anyone know what filter i would have to set to create custom flash sale text in english, spanish and german
Thanks
You are replacing the text correctly, however the issue is that the new string is not found in the language files provided by WooCommerce. The plugin will load a domain called "woocommerce" which is then used to locate strings and their translations if necessary. You are passing the text into __() (more info on __()', '_e(), _x(), _n()), but because your text is new, it isn't found in the dictionary provided by WooCommerce so it defaults to English.
// the __() function can't find 'Sale custom text' in the 'woocommerce' text domain,
// so it does not translate.
__( 'Sale custom text!', 'woocommerce' )
To have this text translate, you will need to load your own language files and text domain and pass the text through __() using your custom domain.
The short version of how to do this:
Use a custom text domain
// load text from 'my_text_domain'
__( 'Sale custom text!', 'my_text_domain' )
Download and install PoEdit to create *.po language files. It has options to scan PHP files for translations entries and will add them to your dictionary. There are tutorials on this on the Internet.
Create one translation file per language that you want to support
Create a folder called languages under your theme directory (this should be a Child Theme so that updates don't overwrite your work), or plugin directory if you are doing your customizations that way.
Update your functions.php (or other plugin, etc) to load your custom text domain. Make sure to use the appropriate path, this assumes it's in the theme.
function load_textdomain_my_text_domain() {
$language_dir = get_template_directory() . '/languages/';
load_plugin_textdomain( 'my_text_domain', false, $language_dir );
}
add_action( 'plugins_loaded', 'load_textdomain_my_text_domain' );
An example of doing this in a plugin using one I wrote:
Spanish language files create by PoEdit under the /languages directory.
Loading the language files under a custom text domain.
Text being passed through __() using the custom text domain.

Localization of a wordpress theme without a textdomain

I have a wordpress theme without textdomain (i.e. e(x) and not e(x,domain)). I also have the .po and .mo files in a folder under /themes/My Theme/localization (Notice the space name in the my theme). I would like to activate fr_FR. I created fr_FR.po and .mo and changed the wp-config to add the locale for fr_FR. However, I am still not getting the french to work. I saw many sites telling you to add a load_theme_textdomain at the top of functions.php, but I do not know what would my textdomain be. Any help will be appreciated.
Youssef
To get theme localization working, you're going to need to go through your theme and add a domain to every _e() and __() function call. this:
_e('some text');
__('some other text');
Will have to become this:
_e('some text', 'your-domain');
__('some other text', 'your-domain');
Next you'll need to add this bit of code at the top of your functions.php file:
load_theme_textdomain( 'your-domain', TEMPLATEPATH.'/localization' );
$locale = get_locale();
$locale_file = TEMPLATEPATH."/localization/$locale.php";
if (is_readable($locale_file))
require_once($locale_file);
You can read more about it in this post.
Add your own text domain. I did this recently to a theme which was not designed for localization, so I'm posting what I did.
Add this to functions.php
load_theme_textdomain( 'your-domain', TEMPLATEPATH.'/languages' );
where your-domain can be any name, but keep it uniform throughout all theme files.
Now go through all the theme PHP files, and do the following:
If you see _e('some text') then change it to _e('some text', 'your-domain');
If you see __('some text') then change it to __('some text', 'your-domain');
If you see "some text" without __() or _e() then,
If "some text" is used in a function call, then make it __() like above, including the text domain
If "some text" is just printed and not part of any function call, surrround it with a _e() like shown above, and don't forget the text domain.
Read the Wordpress internationalization and localization guide for more information.
After an unbelievably long string of forums going through the same steps of how to set it up when everything is working correctly, I finally found what was causing the issue for me.
If the server sets the global $locale before wordpress has a bash at it, then wordpress uses the server's locale settings (in the wp-includes/l10n.php file, the function get_locale).
The solution I used, is to set the global $locale right next to defining WPLANG...
global $locale;
$locale = 'am_AM';
define('WPLANG', $locale);

Is the syntax for the Wordpress style.css template element available anywhere?

I've recently embarked upon the grand voyage of Wordpress theming and I've been reading through the Wordpress documentation for how to write a theme. One thing I came across here was that the style.css file must contain a specific header in order to be used by the Wordpress engine. They give a brief example but I haven't been able to turn up any formal description of what must be in the style.css header portion. Does this exist on the Wordpress site? If it doesn't could we perhaps describe it here?
Based on http://codex.wordpress.org/Theme_Development:
The following is an example of the first few lines of the stylesheet, called the style sheet header, for the Theme "Rose":
/*
Theme Name: Rose
Theme URI: the-theme's-homepage
Description: a-brief-description
Author: your-name
Author URI: your-URI
Template: use-this-to-define-a-parent-theme--optional
Version: a-number--optional
Tags: a-comma-delimited-list--optional
.
General comments/License Statement if any.
.
*/
The simplest Theme includes only a style.css file, plus images if any. To create such a Theme, you must specify a set of templates to inherit for use with the Theme by editing the Template: line in the style.css header comments. For example, if you wanted the Theme "Rose" to inherit the templates from another Theme called "test", you would include Template: test in the comments at the beginning of Rose's style.css. Now "test" is the parent Theme for "Rose", which still consists only of a style.css file and the concomitant images, all located in the directory wp-content/themes/Rose. (Note that specifying a parent Theme will inherit all of the template files from that Theme — meaning that any template files in the child Theme's directory will be ignored.)
The comment header lines in style.css are required for WordPress to be able to identify a Theme and display it in the Administration Panel under Design > Themes as an available Theme option along with any other installed Themes.
The Theme Name, Version, Author, and Author URI fields are parsed by WordPress and used to display that data in the Current Theme area on the top line of the current theme information, where the Author's Name is hyperlinked to the Author URI. The Description and Tag fields are parsed and displayed in the body of the theme's information, and if the theme has a parent theme, that information is placed in the information body as well. In the Available Themes section, only the Theme Name, Description, and Tags fields are used.
None of these fields have any restrictions - all are parsed as strings. In addition, none of them are required in the code, though in practice the fields not marked as optional in the list above are all used to provide contextual information to the WordPress administrator and should be included for all themes.
You are probably thinking about this:
/*
THEME NAME: Parallax
THEME URI: http://parallaxdenigrate.net
VERSION: .1
AUTHOR: Martin Jacobsen
AUTHOR URI: http://martinjacobsen.no
*/
If I'm not way off, Wordpress uses this info to display in the "Activate Design" dialog in the admin backend.

Categories

Resources