mirioki02
Forum Replies Created
-
Forum: Hacks
In reply to: Internationalization for local variables in foreach loopHi all,
Turned out the issue wasn’t due to the foreach loop at all.
The text failed to translate because my text contains apostrophe which was changed to its HTML entity. That’s why the translated text was not found.
I’m going to mark this as resolved but I would like to know how I can escape/encode the apostrophe. I tried esc_attr_e() but the apostrophe is still changed to '.
Thank you esmi and iuttu for your help.
Forum: Hacks
In reply to: Internationalization for local variables in foreach loopTo give a clearer picture about my problem, here’s the excerpt of my code:
<?php foreach ($available_gateways as $gateway ) : ?> <input type="radio" name="payment_method" value="<?php echo esc_attr( $gateway->id ); ?>" <?php if ($gateway->chosen) echo 'checked="checked"'; ?> /> <label for="payment_method_<?php echo $gateway->id; ?>"><?php echo $gateway->get_title(); ?> <?php echo $gateway->get_icon(); ?></label> <?php if ( $gateway->has_fields() || $gateway->get_description() ) : echo '<div class="payment_box payment_method_'.$gateway->id.'" style="display:none;">'; //capture echo output from $gateway->payment_fields() to local variable ob_start(); $gateway->payment_fields(); $field_desc=ob_get_contents(); ob_end_clean(); $field_desc=strip_tags($field_desc); //pass variable to internationalization //My description includes {"Paypal", "Credit Card", "Bank Transfer", "Cash on Delivery"} //This printf returns the same translation for all printf(__('Pay via %s', 'domain'), $field_desc); //This doesn't return translated string _e($field_desc, 'domain'); echo '</div>'; endif; ?> </li> <?php endforeach; ?>
Is there a way for the _e($field_desc, ‘domain’) function to interpret the string in $field_desc variable and send the string value “Cash on Delivery” for translation instead of the text “$field_desc”? Something like
_e(echo $field_desc, 'domain');
I tried this but obviously it’s erroneous.
Forum: Hacks
In reply to: Internationalization for local variables in foreach loopAs I’m already storing domain a local variable from the output buffer, it will the same as doing it from an array. Since the text is not dynamic, as in there’s no change in value, do I need to put it printf()?
I’ve tried _e($local, ‘domain’) before this, but I’ll retry that again when I get back to my workplace. Thanks!
Forum: Hacks
In reply to: Internationalization for local variables in foreach loopIt’s from the checkout page of the Woocommerce plugin. The foreach loop is used to list all the available payment gateways and the description for each. The function echo the description but I’m using ob_start() to capture it to a local variable.
The concern now is how to make sure at each iteration, the text to refer in the .mo file is unique.
Forum: Plugins
In reply to: How to load theme and plugin mo fileI figured it out. The Language settings was set wrongly, that’s why the the mo files where not loaded correctly. Once I change the settings, the theme and plugin’s texts were translated correctly.
Forum: Networking WordPress
In reply to: Multisite for multilingualI’m still testing more plugins so that I can still keep the single installation since I would prefer the different languages uses the same database tables.
Multisite is able to do what I want but like weigertj said, multisite takes more effort and time to update.
Forum: Networking WordPress
In reply to: Multisite for multilingualI’ve tried plugins catering for multilingual such as qTranslate, xili-language but it doesn’t seem to fully fulfill my requirements.
I dislike the implementation of qTranslate that adds data into my database. After I tried that plugin, I needed to delete all the additional tags that were added by the plugin.
I quite prefer xili-language but the issue that I have with it is that my current theme has page template that uses the slug eg. page-slug.php. Since two pages cannot have the same slug, the template cannot be applied. Would it work if I change those pages into custom template instead?
As for multisite, in the long run, I think the maintenance would be quite troublesome.