I have followed the steps about "Internationalisation" on the wordpress codex page http://codex.wordpress.org/Child_Themes
To internationalize a child theme follow these steps:
Add a languages directory.
Something like my-theme/languages/.
Add language files.
Your filenames have to be he_IL.po & he_IL.mo (depending on your language), unlike plugin files which are domain-he_IL.xx.
Load a textdomain.
Use load_child_theme_textdomain() in functions.php during the after_setup_theme action.
The text domain defined in load_child_theme_textdomain() should be used to translate all strings in the child theme.
Use GetText functions to add i18n support for your strings.
What about the last step about using getText functions.
Please give me an example about using the getText function and where should I put these strings?
GetText functions are basically
__('mystring' , 'mytextdomain') and _e('mystring', 'mytextdomain') which is a wrapper for
echo __('mystring', 'mytextdomain')
All strings in your theme should be wrapped this way.
This is all detailed in http://codex.wordpress.org/I18n_for_WordPress_Developers which is a link on the page for creating Child Themes
You should always follow these kind on links in the codex, they give useful information ^^
Related
I am trying to add custom html between <head></head> Doing a hook or something rather than install a module.
But i cant figure how to doit.
I am using bartik and i make this function
function bartik_add_text_to_header(&$vars, $hook) {//}
but i cant figure how or which function to used.
I try with
drupal_set_html_head('style type="text/css">#import url(' . $GLOBALS[base_url] . '/modules/codefilter/codefilter.css);</style>');
But the drupal_set_html_head looks that is not existing in drupal 8 or 9
You should be using a custom theme with bartik as it's base theme rather than the bartik theme itself.
Just make the minimum file for a theme and set the bartik theme as it's base theme.
You can put whatever you want in the head section by overriding the template file that is currently being used to output that part of the html. For Bartik it is a file named html.html.twig in the core/themes/bartik/templates/classy/layout folder.
You would make a copy this file and put it into your custom themes templates folder so your file is used instead of the original.
To easily find what file is currently being used, you can enable twig debugging so comments are output in your html that show exactly what template files are being used.
Having said all that, and seeing as you are only looking to add css, you probably want to check out this page on Adding stylesheets (CSS) and JavaScript (JS) to a Drupal theme which will show you the different options you have to add js and css.
If you are just after a quick answer.... the function you want may be:
function fluffiness_preprocess_page(&$variables) {
$variables['#attached']['library'][] = 'fluffiness/global-styling';
}
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.
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/
I am new in Drupal and try to create my own Drupal theme. I have copied the Garland theme from theme/garland and pasted it to sites/all/themes/(renamed mytheme). But when I search on how to integrate templates in Drupal, there I got that I need four mandatory files: comment.tpl.php, page.tpl.php, node.tpl.php and block.tpl.php but in that theme there is no file name called block.tpl.php, inspite I have a template.php.
Please guide me on this, do I need to create block.tpl.php by myself?? If I create it what would be its content and how do I use that, also what is the use of template.php in my site.
I am new in this CMS (Drupal) so any response would be appreciable and helpful for me.
You can create your own block.tpl.php by copying it form modules/block to your theme's folder (remember to clear the cache!). template.php should contain custom overrides to the theme functions, as well as implementations of process/preprocess hooks. You can find an in-depth discussion about how Drupal's theme system work by following this link and in general by searching drupal.org website.
I've been building basic themes now for nearly a year, and I'm trying to clean up my style as much as possible. But I don't know where to look to find out what this does...
In the kubrick theme php files, for example you get a php tag like this...
<?php the_content('<p class="serif">' . __('Read the rest of this entry »', 'kubrick') . '</p>'); ?>
You see the theme name 'kubrick' weaved in. What is the purpose of this?
You see it in all themes, twentyten, twentyeleven, etc.. but I never notice a difference if I leave it the same. What benefits does this have if I change it to my current theme name?
Can anyone enlighten me? or point me in the right direction?
Thanks
Josh
This is the 'theme text domain' and is typically used for localization. You can find out more by reading the gettext filter reference. One note is that the text domain is not required to be the same as your theme name. You can make it whatever you want as long as you are consistent with what you load using load_theme_textdomain. It's just convention to make it the same as your theme name. Finally, as to why you should bother including a domain here is a quote from an article called How to localize WordPress themes and plugins with GetText:
Have you noticed the 2nd argument in the GetText calls? It’s an
optional argument that tells GetText what the scope (domain) of the
texts is. If supplied, this GetText will return the translations only
from the dictionary that you supply with that domain name. Although
optional, specifying the translation domain is highly recommended.
Without it, GetText might return a different translation, if the same
string also appears in a different plugin, or in WordPress.