I need to translate Choose File & No file chosen to another language (Japanese).
The following code is from acf field.
I looked into the code but there are no Choose File & No file chosen.
Would you please let me know how to translate them in this case?
<div class="acf-input">
<div class="acf-file-uploader" data-library="all" data-mime_types="" data-uploader="basic">
<input type="hidden" name="acf[field_60bc51d8898c5]" value="" data-name="id"> <div class="show-if-value file-wrap">
<div class="file-icon">
<img data-name="icon" src="" alt="">
</div>
<div class="file-info">
<p>
<strong data-name="title"></strong>
</p>
<p>
<strong>File name:</strong>
<a data-name="filename" href="" target="_blank"></a>
</p>
<p>
<strong>filesize:</strong>
<span data-name="filesize"></span>
</p>
</div>
<div class="acf-actions -hover">
<a class="acf-icon -cancel dark" data-name="remove" href="#" title="Delete"></a>
</div>
</div>
<div class="hide-if-value">
<label class="acf-basic-uploader">
<input type="file" name="acf[field_60bc51d2899c5]" id="acf-field_60bc51d2899c5">
</label>
</div>
</div>
</div>
Thank you.
If you want to translate just a handful of words and not the entire plugin, then you could use the following method!
So, every well-developed plugin/theme has a text domain associated with it, so that you could hook into it and manipulate any text generated by that plugin/theme. For example text domain for woocommerce plugin is woocommerce! For ACF plugin, it's acf!
Usually you could find the text domain in the main file of the plugin. For ACF plugin you could find it in the acf.php located in the root directory of the plugin. See the screenshot below!
After you found the text domain then you could hook into it using gettext, ngettext etc. filter hooks! See the code below:
add_filter('gettext', 'your_theme_translate_acf_fields', 20, 3);
function your_theme_translate_acf_fields($translated, $text, $domain)
{
if ('acf' == $domain) :
switch ($translated) {
case 'No file chosen': // THIS IS THE TEXT GENERATED BY THE ACF PLUGIN
$translated = 'ファイルが選択されていません';
break;
case 'Choose File': // THIS IS THE TEXT GENERATED BY THE ACF PLUGIN
$translated = 'ファイルを選ぶ';
break;
}
endif;
return $translated;
}
Notice: Capitalization matters!
Code goes to your functions.php of your active theme. Tested and works!
Wordpress translation filter hooks:
gettext
ngettext
If you want to translate any plugin first, check the .pot file. The file is inside wp-content>plugins>plugins-name>languages. You can edit the file with POedit. You can translate to any language.
Related
I am trying to insert a custom tag after H3 tag with a certain class by inserting code into my theme's function.php file. Below is what I am doing but unable to achieve it.
If I have this, showing on a page currently:
<h3 class="title">TITLE HERE</h3>
<div class="desc">
I would like to insert a tag after h3 tag. Below is what I am trying to insert intp my theme functions.php file:
echo '<h3 class="title">TITLE HERE</h3>
<a tooltip="This is a test">TEST</a>
<div class="desc">'
As a result, I am just getting 'TEST' on the top of the page instead of showing it after the h3 tag.
Can you try this first.
Add **<div style="clear:both;"></div>** after your closing </h3> tag
OR
I think you are creating shortcode in function.php file. If you directly echo in your function then this problem will arise. First you assign the value to variable which you want to echo and then return this variable.
Eg:
function my_fun(){
$text='<h3 class="cuzd-title"> TITLE HERE</h3> <div style="clear:both;">
</div> <a data-tooltip="THIS IS TEST">TEST</a>';
return $text;
}
add_shortcode( 'shortcode_name', 'my_fun' );
now where you want these to be display just use
echo do_shortcode('[shortcode_name]');
I'm building a wordpress site (here: http://dev.tps.entropii.com/contact-us/) that requires a full page width google map on the contact page. The Business has two addresses so they effectively need two maps with a means to switch between them. I'm using Advanced Custom Fields plugin to give the user the functionality to update/edit their addresses.
Here's the problem. In order to give the functionality to switch back and forth between the two maps I decided to put them inside a twitter bootstrap carousel. One slide for each map. This works as expected with one problem. The map that is contained within the inactive slide (e.g. the slide that doesn't have the class 'active' on page load), doesn't seem to fully load. If I put the maps side by side on the page without the carousel they load no problem.
Because I'm using advanced custom fields, the maps are being loaded using php. Here's the HTML/php from my template file:
`
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<!-- map 1 -->
<?php $map1 = get_field('map_1'); if( !empty($map1) ): ?>
<div class="acf-map" id="map1">
<div class="marker" data-lat="<?php echo $map1['lat']; ?>" data-lng="<?php echo $map1['lng']; ?>"></div>
</div>
<?php endif; ?>
</div>
<div class="item">
<!-- map 2 -->
<?php $map2 = get_field('map_2'); if( !empty($map2) ): ?>
<div class="acf-map" id="map2">
<div class="marker" data-lat="<?php echo $map2['lat']; ?>" data-lng="<?php echo $map2['lng']; ?>"></div>
</div>
<?php endif; ?>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#map-carousel" data-slide="prev"></a>
<a class="right carousel-control" href="#map-carousel" data-slide="next"></a>
</div>`
My suspicion is that because the inactive slides of the bootstrap carousel are set to display none, that the content isn't being loaded int he first place properly. However I'm completely stabbing in the dark. Can anyone shed any light on this?
Let me know if you ned any more info. Thanks,
I have a shortcode that I put in my post but somehow it doent execute for some reasong. Here is the code I have:
short-code.php:
add_shortcode('teammate',function($atts){
$classes=$atts['country'];
$imgUrl=$atts['img'];
$name=$atts['name'];
$description=$atts['description'];
echo '
<div class="member "'.$classes.'>
<div class="member-img">
<img src="'.$imgUrl.'">
</div>
<div class="member-desc">
<h1>'.$name.'</h1>
<p>'.$description.'</p>
</div>
<div class="clear"> </div>
</div>
';
});
Here is how I include the file in functions.php:
$includes = array(
'includes/theme-options.php', // Options panel settings and custom settings
'includes/theme-functions.php', // Custom theme functions
'includes/theme-actions.php', // Theme actions & user defined hooks
'includes/theme-comments.php', // Custom comments/pingback loop
'includes/theme-js.php', // Load JavaScript via wp_enqueue_script
'includes/sidebar-init.php', // Initialize widgetized areas
'includes/theme-widgets.php', // Theme widgets
'includes/short-code.php', // Custom shortcode file for side menu
'includes/team.php' //team shortcode
);
and here is what i put in my page:
<div class="outer-members">
<div class="inner-members">
[teammate name="Darko Petkovski" img="http://myurl.com/myimage.jpg" description="test" country="mc"]
</div>
</div>
Seems that the code is working ok, but the only problem is that shortcode isn't executing outside wp.
Imagine you have the following scenario:
In you application, you have several models that are "Commentable". Comments are shown in
an identical manner and can thus utilize the same template. In the default view of the
comments widget, the two most recent comments are shown, with a link to load remaining X
comments.
The widget also have a form (i.e textarea that submits on enter-key) for adding a new
comment to the model.
Given the above requirement, where is a reasonable place to generate the links that the form and load-link needs to do its work?
Should the links be generated in the view that calls the template, together with the Commentable model? i.e.
<?php
echo $this->partial('path/to/template/comments.phtml', array (
'add-link' => $this->url($params, $routeName),
'load-link' => $this->url($params, $routeName),
'comments' => $this->model->getComments()
);
Is it, at all, acceptable to ask the Commentable for these links? I.e in the comments.phtml-template:
<div class="comments">
<div class="loadLink">
<a href="<?php echo $this->comments->getLoadLink() ?>">
<?php echo sprintf('Show all %d comments', count($this->comments)); ?>
</a>
</div>
<div class="container">
<?php
foreach ($this->comments->getFirst(2) as $comment) {
echo $this->partial('comment.phtml', array('comment' => $comment);
}
?>
</div>
<div class="addComment">
<form action="<?php echo $this->comments->getAddLink() ?>" method="post">
<div>
<textarea class="autogrow" name="comment"
placeholder="Write a new comment" rows="1" cols="80">
</textarea>
</div>
</form>
</div>
</div>
Since MVC advocates that the view can communicate with controllers, is route generation viewed as a way to "communicate" with a controller, even if it doesn't do so in an object-to-object manner?
In an MVC application you should never ask the model to construct a link. You should add some view helper that may use the model to generate these links.
I'm using Drupal 6.x. This is my code on my node-product.tpl.php template. I've created a custom jquery gallery for the products. It works great, but I'm just missing tool tips from my images (both large and small thumbnails). To upload images I'm using a CCK field named field_images. There I input the image titles when I upload the images. How can I add the tool tip code snippet to make it work?
<div class="product-large">
<img src="/sites/default/files/imagecache/360x280/<?php print $node->field_images[0]['filename']; ?>" />
</div>
<div class="product-small">
<?php
// get all images
foreach ($node->field_images as $images) {
?>
<img src="/sites/default/files/imagecache/120x90/<?php print $images['filename']; ?>" rel="/sites/default/files/imagecache/360x280/<?php print $images['filename']; ?>" />
<?php
}
?>
</div>
Thanks much appreciated!
Chris
The "tooltip" is a result of the title HTML attribute. You'll want to add title="foo" to your img tag.
Perhaps:
<img src="/sites/default/files/imagecache/120x90/<?php print $images['filename']; ?>" rel="/sites/default/files/imagecache/360x280/<?php print $images['data']['filename']; ?>" title="<?php print $images['title']; ?>"/> for the second image and similarly $node->field_images[0]['data']['title'] for the first.