In elgg chinese language not loading? - elgg

I am use elgg 1.8. in that i use zh means Chinese language. in one page i need a page without header and footer so i just make a page handler and echo content with elgg_echo function. it work with the en (English) language but when i change to zh it's display a garbage values.
I am also use this trick for that
echo elgg_echo('user:chinese_zodiac','zh');
but it works on en language but not for zh. this function also display same garbage value like this 生肖 but i want text like 生肖.

Thanks, guys trying to help me. but finally i got the trick.
I am use this function or trick to handle this problem...
reload_all_translations();
This function reload all translations from all registered paths.
This is only called by functions which need to know all possible translations.

Related

WordPress responsive menu in chinese language

I am using this plugin in my wordpress website.
https://wordpress.org/plugins/wp-responsive-menu/
But when i translate my website in chinese language menu items not showing. Please can you suggets me how i can translate it?
in this plugins, the folder "lang" is empty... It does not use languages. So you need change php files and i recommend you do not do this.
But if you really need change, use sublimetext or other soft or command line for use best function : "search in folder".
Use WMPL[Multilingual Plugin].
Just install this plugin in your website and just translate each and every menu which has been used in English.{you can even Sync the menus to the selected language}.
When you choose your language the menu gets changed to Chinese language and nothing get affected.
You will most probably need to either change the page encoding or if use an approach like in this answer.
(HTML5) cannot display Chinese characters when using UTF-8

Parsing page data into sidebar - wordpress

What would be the proper procedure for accessing the current page html data and picking up all of a certain tag and throwing them into the sidebar as links?
I'm not sure your proficiency with php, but I'll give you and overview of what you'd probably want to do.
First, you need the HTML. I'm assuming you're running this on a page (in a page.php file or single.php file, or similar), this means that you have access to the global variable $post, which contains the html of the page in it. To access it you can use the helper function get_the_content(), this returns the html being displayed.
Next you need to parse through this to get the h2 tags. A simple regex can handle this, something like <h2[^>]*>(.*)</h2>. It's important to remember that this regex is very picky, so format your html correctly, no multiline h2s.
So now you have the html, and have parsed it with a regex to get the h2s. Now you need to generate the list from the results, and prepend it to the top of the content of the page. There are a ton of ways to do this, the easiest being just running the code in the right spot in the template file.
Of course there are probably better ways of doing this, I'd recommend you look at say a FAQ plugin (if that's what this is for), or do the lists manually (as this system can be broken), or possibly use a custom post type; but for your question, that's how I'd do it.

PHP code inside WP molecule

I need to add a PHP snippet inside a molecule in WP. WP Editor allows to insert <code> </code>
but even if I wrap PHP with that it does not seem to help.
All I want it to insert the current year, so I'm OK with either PHP or JS or whatever else WP supports.
Anyone had experience with that?
There are two plugins that come to mind. One is wp-syntax http://wordpress.org/extend/plugins/wp-syntax/, a rich code display plugin with many features. You'll have to switch to code editing view to insert your <code> or <pre> tag with the PHP snippet.
The other one is a low tech homebrew of mine, "include custom field": http://pp19dd.com/wordpress-plugin-include-custom-field/
The homebrew is a shortcode plugin that lets you place arbitrary code or data inside a custom field, and then inject it into the post with something like [include mycode1]. Note that it'll be up to you to encode it to where it can be shown, or modify it to where it acts like a code highlighter (can be done easily with highlight_string.)
Reason I like my brew version is because it a) separates a blog post from the code, and b) survives numerous editing cycles and/or imports. All other inline solutions annoy me to no end.

drupal translation t() function doesn't do anything...outputs the same text

I've read that using the t('text to translate') I can translate texts in drupal templates. The problem is, this function doesn't do anything. It simply outputs the same text.
I already have a site and I have installed the proper modules so that's not the problem.
I am using this to translate the titles for the blocks in block.tpl.php.
<h2><?php print t($block->subject); ?></h2>
So this outputs the same original text i'm defining in the title of the view as the block. Why? If I had an error shouldn't Drupal output something or log that error at least?
Translation is not magic. You also need to set up the language of your site in something else than english and be sure that the string you display have a translation.
You can check this at this page : exemple.com/?q=admin/build/translate/search (d6 url)
for the t function to work, you have to do the following:
enable the optional core modules called locale (for interface items) and optionally the content translation (for content).
grant the proper permissions for the proper roles
go to site building -> translate interface to access the interface translation page.
hope that helps
-peter
The translation is not being displayed because its not there. You need to add the translation of that particular string, only then the translated string would be rendered. If you have all the required modules in place, then you need to go to "admin/config/regional/translate/translate" and then search for your string; then click on edit and add the translation of that string.
You also need to install the Locale module and provide translations in the languages you want to support.

How does one inject variables into page templates from a custom Drupal module?

We've created a custom module for organizing and publishing our newsletter content.
The issue I'm running into now -- and I'm new to theming and Drupal module development, so it could just be a knowledge issue as opposed to a Drupal issue -- is how to get each newsletter themed.
At this point the URL structure of our newsletter will be:
/newsletters/{newsletter-name}/{edition-name}/{issue-date} which means that we can create template files in our theme using filenames like page-newsletters-{newsletter-name}-{edition-name}.tpl.php, which is great. The one issue I'm running into is that all of the content comes through in the $content variable of the theme. I'd like to have it come through as different variables (so that I can, inside the theme, place certain content in certain areas.)
Is there a proper way for doing this?
Edit: To answer some questions: The issue is a node (there are issue, edition and newsletter nodes) and the path is being set using hook_menu with wildcards and a router.
The best answer I could find was to add a check inside of phptemplate_preprocess_page to send the vars back to the module and have them be updated.
Like so:
function phptemplate_preprocess_page(&$vars) {
if (module_exists('test_module')) {
_test_module_injector($vars);
}
}
then in my test_module.module file I created this function:
function _test_module_injector(&$vars) {
$vars[] = call_to_other_functions_to_load_vars();
}
It seemed to work. I wish there was a way to do this without having to touch the theme's template.php file, but otherwise this works well.
If there were better documentation for template preprocess functions, Drupal would be a lot more accessible - as it is, you need to piece together the information from a lot of different explanations. One place to start is here:
http://drupal.org/node/223430
but if you take the time to work through the tutorial below, you'll find you can do most things:
http://11heavens.com/theming-the-contact-form-in-Drupal-6
This is an old post, and the OP's issues seems to have been solved.
However, just for others finding this through Google (or otherwise):
Install the 'Devel' module: http://drupal.org/project/devel
Also the 'Devel Themer' module: http://drupal.org/project/devel_themer
Use Devel Themer to go through the $content variable and find what you need to pull out.
There are a bunch of Devel/Themer docs/tuts out there, but its usage is pretty straightforward. Note, though, that some stuff in there will need to be sanitized before printing in the theme.
The suggestion to show the node as a View and then modifying the view templates sounds pretty crazy, though it'll work.

Resources