Joomla custom component translation compatibility

What would be the best solution for compatibility of the joomla3.1 compatible language platform? I mean that the site works in three languages, my component should be able to display the translated elements of my component

realestates --realestate(items) - en-EN --realestate(items) - de-DE --realestate(items) - cn-CN 

It would be a good workaround to expand my position table with the translation column, which saves the translation language code every time the request takes this into account.

 select * item from realestets where translation = 'en-EN' 

or is there a better way to do this?

+4
source share
1 answer

In order for your component to be multilingual, you need to define the language files that are stored in the language folder on both the administrative and public sides of the website. These language files are .ini files that must be defined for each language that you want to include. Therefore, if you are making English and Dutch .ini files, the files should be in:

/language/en-GB/en-GB.com_yourcom.ini

/language/nl-NL/nl-NL.com_yourcom.ini

Then each line should be passed to the translator method _() (yes, this is the underscore) in the JText class, for example:

JText::_("COM_YOURCOM_STRING") where COM_YOURCOM_STRING is just a string in your component.

I recommend using short line descriptions if the line you are translating is a large block of text.

EDIT: For your specific case, I would add the translation_id column to your table where the items are stored. Then create a new table with 3 (or 4) columns where the translations are stored:

id, item_id, (language), translation

In your xml component, you can add an entry that generates a drop-down list to determine which language your element is in. If it is nothing but the default language, it should create a new entry in the translation table.

I would also suggest watching how Joomla! manages languages ​​inside and Joomfish also works!

Good resources:

http://docs.joomla.org/Embedding_translatable_strings_in_the_template

http://docs.joomla.org/Specification_of_language_files

http://docs.joomla.org/Language_Guidelines_for_3rd_Party_Extensions

+3
source

All Articles