I seem to have a problem loading Wordpress language files into my custom theme.
In functions.php I have the following code in my setup:
load_theme_textdomain( 'theme_textdomain', get_template_directory() . '/langs' );
In my stylesheet I have the textdomein defined:
Text Domain: theme_textdomain
In my theme folder I have a folder /langs with 2 different file types:
en_GB.mo
nl_NL.mo
Default language of my theme is nl_NL.
In one of my templates I use:
<?= __('Zoeken'); ?>
Just to test I added a translation of this in both language files:
For en_GB = search, for nl_NL = zoeken2. However, both nl_NL and en_GB are not being loaded by the theme. What I'm I doing wrong?
I think you need to specify your theme domain in your call to the __() function. I don't think it's picked up automatically from your stylesheet header. So rather than
<?= __('Zoeken'); ?>
try
<?= __('Zoeken', 'theme_textdomain'); ?>
Related
Hello i have writen 3 step multipage form in php
Files in form:
first step: start.php
second step: form.php
last step: payment.php
I wonder if there is a way to add this form in wordpress template to page.php file or something?
My form is similar to this https://www.formget.com/multi-page-form-php/
You can include external files in your site by using the Get Template Part function
Here is the function in the codex
You can use it to include any php file that you wish, see the naming convention at bottom of the codex page
So i make custom template files with something like this
<?php
/*
Template Name: OrderBM-1
*/
get_header();
include (TEMPLATEPATH . "/orderForm/start.php" );
get_footer();
?>
Files that i include, i paste in theme directory "wp-content/templates/temp-name/orderForm"
I'm trying to add a Dutch translation to a Wordpress theme.
I have edited .pot file (inside the theme) with POedit, and saved nl_NL .po and .mo (without any issues).
Naturally, I've made languages directory in my childtheme (called charityhub-child).
I have changed my code in the most basic form (taken from Wordpress Code reference).
My functions.php looks like this:
function wpdocs_child_theme_setup() {
load_child_theme_textdomain( 'charityhub', get_stylesheet_directory() . '/languages' );
}
add_action( 'after_setup_theme', 'wpdocs_child_theme_setup' );
Parent theme name = charityhub.
What seems to be the problem here ? Language files are not loading...
I am programming a custom template in Joomla 3.3. I need to override some language strings, so I have created a folder called language/templates/mytemplate/language/es-ES/ and inside it, I placed a file called es-ES.custom.ini.
In template index.php file I placed:
<?php
$language =& JFactory::getLanguage();
$result = $language->load('custom' , dirname(__FILE__), $language->getTag(), true);
echo $result;
?>
$result variable is true indicating the file is correctly loaded, but the strings are not actually overridden.
Any help will be appreciated.
If you enable Language Debugging in your admin area:
you'll notice that even if your custom language file is loaded, other language files are loaded later, overriding your strings.
A different approach would be to create a file called JROOT/templates/YOURTEMPLATE/language/overrides/es-ES.override.ini. Then add the following to your templateDetails.xml:
<languages folder="language">
...
<language tag="overrides">overrides/es-ES.override.ini</language>
</languages>
This is described more in detail here.
I have the latest version of Wordpress and CiviCRM installed and for some reason CiviCRM won't enqueue the jQuery files necessary on my custom theme but it does indeed work if I switch the custom theme to the default WP theme. How is this possible? I disabled all my plugins, functions.php file, created a very simple page.php template (update: i even created a simple theme with just a style.css and index.php file):
<?php
wp_head();
if (have_posts()) {
while (have_posts()) {
the_post();
the_content();
//
} // end while
} // end if
wp_footer();
?>
and I receive the following JS error:
Uncaught ReferenceError: cj is not defined
Any help would be appreciated, thanks.
It seems like plugins>civicrm>js>jquery.conflict.js may not have run; but why I can't say. What jQuery*.js files does your new WP theme contain? CiviCRM wants to use 'cj' as an alias for jQuery. Can you step thru in Firebug?
When using gettext in Wordpress to create a bilingual theme, do we have to create one .php file for every page twice (English, French)? For example, header.php, header-fr.php, sidebar.php, sidebar-fr.php, taxonomy-types.php, taxonomy-types-fr.php, etc. Sidebar-fr.php would then use _e('Text to translate', 'domain'). Is there a way to simply keep one copy of all php files and to switch the locale?
Thank you.
Create languages folder inside the theme directory, that's where you save language files, e.g. ar.po (for Arabic).
When writing strings in the code use the following (I usually use English text as the default text, so I won't need to create extra language file, and for each other language create files):
<?php echo __('This is a test','my_theme_name'); ?>
<?php _e('This is a test','my_theme_name'); ?>
in functions.php in the theme folder add the following code to load the language file (please note my_theme_name as given above):
add_action( 'after_setup_theme', 'my_theme_setup' );
function my_theme_setup(){
load_theme_textdomain('my_theme_name', get_template_directory() . '/languages');
}
This way you create only one file(header.php, index.php, etc), where strings are easy to translate.
[Note: this answer assumes that you have knowledge in how to create gettext translation files]