Latest Register Log In

+ Advanced Search

Using multiple languages for fields

Using multiple languages for fields
By
Aug 15, 2004 (Edited Jun 25, 2014)

For true mutlilingual support, you may want to have listing and category info in several languages and display in the appropriate language for each visitor. As of the 9.0.14 release, this is handled automatically for category names and descriptions and listing names and descriptions. Note that if the currently selected language isn't available for a category/listing, the version in your default language (as set at Admin -> Customizations -> Language) will be shown.

To apply to other fields, or for older versions, read on. New listing fields of the form languagenametitle and languagenamedescription will be automatically displayed as the value for {LINKTITLE} and {LINKDESCRIPTION} when the languagename language is selected and we're not on the add/edit pages. For example, the value of the field spanishtitle will automatically show as a link's title when browsing in Spanish. If a translation is not available for the user's selected language, the regular field's content will be shown (fallback is automatic).

Important: Make sure you decide which of your languages is the default language, and only add new fields for non-default languages. Let the default language use the standard fields.

For Additional Link Fields In WSN 9.0+

Go to Admin Panel -> Listings -> Link Fields and click "Add New Link Field" at the top. Fill out the selections to match the standard version of the field (check the edit field page for the standard field), but specify in the title/description which language it's for. Then in the "Template Variable:" area be sure to change the template variable name to LANGUAGENAMEFIELDNAME -- so for a Spanish listing title, use SPANISHTITLE.

If you're translating the listing description field, you'll need to make a few changes to the custom input html. Start by copying the standard field code:

<textarea name="description" id="description" class="submitdescription">{LINKEDITORCONTENT[description]}</textarea>
<p class="charsleft"><span id="counter_description">{LINKDESCRIPCHARSLEFT}</span> {LANG_SUGGESTLINK_CHARSLEFT}</p>
<IF {SWITCH_WYSIDESCRIP}><p class="editormodeops"><select name="editormode">{EDITORMODEOPS}</select></p></IF>

Then bulk replace every instance of description with spanishdescription (or yourlanguagedescription), and finally change class="submityourlanguagedescription" back to class="submitdescription".

For Other Types of Fields, or Earlier Versions

Go to Admin Panel -> Customizations -> Add Fields and add new fields for each language/field you want to make multilingual. You're most likely to want to do title and description for links and then name and description for categories.

For an example, to have French versions of the category names and descriptions go to Admin Panel -> Customizations -> Add Fields and add the category fields french_name and french_description (assuming the language pack is named languages/French.lng).

If you're doing listing description fields for different languages, you'll want to have the WYSIWYG editor and character counter just like the regular description field. The basic textarea you get by adding your custom field doesn't get you that, so remove that textarea from your custom fields template. Then, copy the description code from the submit/edit templates:
<tr>
<td class="labelscolumn"><span class="labels">{LANG_GENERAL_DESCRIPTION}:</span>
<IF {LINKSMILIESALLOWED} or {LINKCODESALLOWED}>
<ul>
<IF {LINKCODESALLOWED}><li>{LANG_GENERAL_USECODES}</li></IF>
<IF {LINKSMILIESALLOWED}><li>{LANG_GENERAL_USESMILIES}</li></IF>
</ul>
</IF>
<IF {SWITCH_WYSIDESCRIP}><p class="center"><select name="editormode">{EDITORMODEOPS}</select></p></IF>
</td>
<td class="optionscolumn">
<textarea name="description" id="description" class="submitdescription">{LINKEDITORCONTENT[description]}</textarea>
<p class="charsleft"><span id="counter">{LINKDESCRIPCHARSLEFT}</span> {LANG_SUGGESTLINK_CHARSLEFT}</p>
</td>
</tr>


You'll need to make a few changes to this to adapt it to your new field to use it with the frenchdescription field:


  • Change {LANG_GENERAL_DESCRIPTION} to {LANG_CUSTOM_FRENCHDESCRIPTION} after adding the custom_frenchdescription language item (so that it'll say "French Description" instead of just "Description").
  • Bulk-replace every instance of description with frenchdescription.
  • Change <p class="charsleft"> to <p class="charsleft_frenchdescription">
  • Change <span id="counter">{LINKDESCRIPCHARSLEFT}</span> to <span id="counter_frenchdescription">{LINKDESCRIPCHARSLEFT[frenchdescription]}</span>
  • Change maxlen to maxlen_frenchdescription

Completed frenchdescription example:

<tr>
<td class="labelscolumn"><span class="labels">{LANG_CUSTOM_FRENCHDESCRIPTION}:</span>
<IF {LINKSMILIESALLOWED} or {LINKCODESALLOWED}>
<ul>
<IF {LINKCODESALLOWED}><li>{LANG_GENERAL_USECODES}</li></IF>
<IF {LINKSMILIESALLOWED}><li>{LANG_GENERAL_USESMILIES}</li></IF>
</ul>
</IF>
<IF {SWITCH_WYSIDESCRIP}><p class="center"><select name="editormode">{EDITORMODEOPS}</select></p></IF>
</td>
<td class="optionscolumn">\n<textarea name="frenchdescription" id="frenchdescription" class="submitdescription">{LINKEDITORCONTENT[frenchdescription]}</textarea>
<p class="charsleft_frenchdescription"><span id="counter_frenchdescription">{LINKDESCRIPCHARSLEFT[frenchdescription]}</span> {LANG_SUGGESTLINK_CHARSLEFT}</p>
</td>
</tr>


You'll likely want to place your alternate language descriptions right below the main language description in the submit listing and edit listing templates.

You can also make multilingual category description fields use WYSIWYG by copying the standard description from the submit category/edit category templates and making the same changes.

Note that the multiple-language character counter only works since WSN 8.0.14, and the WYSIWYG character counter since 8.0.0.





Description How to make each category and listing available in multiple languages seamlessly.
Rating
Views 1,367 views. Averaging 0 views per day.
Similar Listings