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

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.

Related

Cannot convert application to multi-lang and keep current content translatable

We have an application built on Symfony-CMF which is running fine. We now have a requirement to add locales and translations to the content. We have set up one page (/contact) with various locale specific routes (e.g. /en/contact and /fr/contact) and we are able to visit those URLs and edit the content for each language independently. However, we are not able to see the existing content so when we hit /en/contact all the editable content areas are blank.
By rebuilding our app and loading the content (via fixtures) with the relevant multi-lang config in place, we are able to see the original content in place but when we edit it, it seems to edit it for each language. So when we go to /en/contact and edit the content there, we see that change reflected at /fr/contact and vice versa.
We have added the following config:
doctrine_phpcr:
odm:
locales:
en: ~
fr: [en]
de: [en]
cmf_core:
multilang:
locales: [en, fr, de]
We have BasicPage class for our documents:
/**
* #PHPCR\Document(referenceable=true,translator="attribute")
*/
class BasicPage extends Page implements SeoAwareInterface, SitemapElementInterface
{
/**
* #var string
* #PHPCR\String(nullable=true,translated=true)
*/
protected $intro;
...
}
Is there something else we need to do to make the original content translatable?
how do you load the fixtures now? do you use bindTranslation to store content in multiple languages? otherwise you will only create one language version of the content.
when editing, the language you load the document in is the one you store back to, unless you explicitly specify its a different language. (usually, you would change the field that is mapped to the locale of the document).
in your case, if the document is only translated to english currently and you ask for the document in french, phpcr-odm will fall back to english and give you that document. you then edit that and save it back, updating the english version. best is mapping the locale on a field and either expose it to the editor for explicitly specifying the locale or use a content language parameter in the url to avoid confusion.
you can ask the document manager for available translations as well, if you want to show that information.
by the way, we are currently working on providing a tool to convert non-translated documents to translated documents and vice versa: https://github.com/doctrine/phpcr-odm/pull/655 . if you want to check this out, feedback is highly appreciated.
Ok so I managed to figure this out myself (partly due to the info provided by dbu and partly thanks to xdebug!) The cmf_create inline editor was generating ajax requests to update the documents but these were using the default locale rather than the locale specified in the request. Setting cmf_create.rest_force_request_locale to true as specified in the CMF docs worked and means we can edit each language separately when loaded from our fixtures. We still need a migration to make each document translatable but we may be able to leverage the converter tool as mentioned by dbu.

In elgg chinese language not loading?

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.

TinyMCE 3.5.8: Detailed Steps for Creating a Button that Acquires a Value from User and Inserts it Between a Pair of Tags

TinyMCE 3.5.8
I merely need to create a button (and module) that acquires a user-entered value from a popup and places it between two tags, e.g., [bib][/bib]
I am having trouble finding a "step-by-step" for doing this, including what files, where code goes, etc. This must be rather simple?
I have replaced all of the occurrences of "example" with my module name in the "Example" module, but that is where my information ends.
If someone would be so kind !
P.S.: It would be even better if the form field would javascript validate for "integer", but maybe I ask too much?
download the tinymce development version
use tiny_mce_dev.js instead of tinymce.js for developement in order to get more usefull error messages
create an own tinymce plugin (this is not that difficult) that opens a popup
get the content of a popup field
insert it at the right place in the editor
You should have a look at other tinymce plugins (in the plugins directory under the tiny_mce dir) to get to know how some things work. There are many plugins, some of them use popups.
I.E. the searchreplace popup

Add a Drupal menu item with a hard coded path to a view that accepts arguments?

I have a view page that accepts a taxonomy term id as an argument at /foo/%bar. I want to add several menu items to the primary links in the form of /foo/actual-bar.
Whenever I try to do this I get the error message "The path '/foo/actual-bar' is either invalid or you do not have access to it."
How can I add such menu items?
Thanks,
Finbarr
Off the top of my head I believe there are a couple ways to do this:
Use absolute URLs (http://yoursite.com/foo/actual-bar) in the menu, which should bypass the check.
Define the links in a custom module using hook_menu()
It does seem to me that there should be a better way to achieve this, but these two options should at least get your going in the short term.
Another way would be to set the url in the view to foo/% it makes the argument required and the 6.x menu system will then see it as a valid URL.
However, just /foo will no longer be a valid URL, so you may need to create another page display in the view to accommodate the URL with no argument.
i recommend set path in such way: /foo/%/bar
so you can access it via: /foo/actual/bar
Oddly, I have a custom module that defines a hook_menu but the menu UI won't allow me to enter it into the system.
Had to do the absolute path solution... though I sure don't like it!

Specifying edit paths in Drupal for FCKEditor?

With the FCKEditor, you can specifiy paths where the editor must be included. Eg.
node/add/email
Which works great, until you need to go back and EDIT that node. Which means you end at a path like so:
node/284/edit
Now, the fck editor no longer works, because the path isn't valid.
Is there any way that one can get the FCKEditor to work for both the normal path and the edit path of ONE SPECIFIC CONTENT TYPE?
I'm not sure if you can do this with stock the FCKEditor module. However, you can do it by using the WYSIWYG API module, which allows you to specify WYWIWYG editors on a per-input-filter basis, and Better Formats, which allows you to set input filter formats on a per-node-type basis.

Resources