multilingual Tag

Suppose my website provides bilingual GUI, English and Chinese. I am posting a blog, I input two tags with one is in English and another is in Chinese, but both have some meaning. When people visit this post, if in English GUI, only the English tag will be displayed. On the other hand, only Chinese tag will be display in Chinese GUI.

Is there any way to implement it, to dispaly tag dependenting on language? 

  • I don't see an easy way to do this. First you need to check the language of the user. Then you will have to do some kind of tag filtering before displaying it, basing on the language of the user.

    And to do that filtering you need to do some comparing to detect which language the tag is written.

    Rodolfo Hernandez

    Arvixe/Elgg Community Liaison


  • Yes, it seems impossible to detect UTF-8 chars into different language chars.

    Not sure if there is other solution?

  • They only other solution would be to save two different sets of tags. An English version (tags_en) and a chinese version (tags_zh) and then pull up the relevant ones depending on a check of current user's language.

    It will become fiddly for users posting content to have to do it this way, but I can't see another solution at the moment.

  • utf-8/ unicode uses diff (non-overlapping) byte-sets for each lang's alphabets. so if 2 lang's tag are stored as AB01 and DF53 - each of the tags gets picked up for exactly what they are - with no mistakes. there should be no issues (with db tbl`s defined w/ utf8 unicode ci collating & input being typed in correctly as proper unicode chars).

     0x0370-0x03FF  880-1023  Greek
     0x0590-0x05FF   1424-1535  Hebrew 
  • Thanks Trajan and DhrupDescoop. 

    Hi Trajan, I just want to have bilingual tags for web site public content only, not for user's content. Will your solution need to modify Elgg core code? what code should be modified?

  • are you trying to do something like this ?


  • No.

    Assume my web site provides bilingual GUI, Chinese and English. At first I created a item "Hello Chinese & Hebrew", I set two tags as "你好" and "hello" for it. Then if user 1 who selects Chinese GUI and visits this item, only tag "你好" displays with this item. If user 2 who selects English GUI and visits this item, only tag "hello" displays with this item. 

    The same, in tag cloud, either "你好" or "hello" display based on the language GUI, but not both display together.

    Hope it clarifies.

  • I review the core file engine/lib/tags.php, seems I can use the function elgg_register_tag_metadata_name. If use metadata "ctags" for Chinese tags, metadata "etags" for English tags, then when the user select Chinese GUI, will call elgg_register_tag_metadata_name("ctags") and unregister "etags", otherwise call elgg_register_tag_metadata_name("etags") and unregister "ctags".

    But I wonder why there is not funciton for unregister tag metadata name, e.g. "elgg_unregister_tag_metadata_name".



  • So.

    You do not realy mean 'No' -- because the (live) example I posted is at least 50% of the solution that you are seeking.

    The only additional aspect is to filter out & not display the non-User's language tags on the search results page.

    The direction you've tried to demonstrate - using elgg_register_tag_metadata_name() and the non-existent elgg_unregister_tag_metadata_name - is a rather much longer way to achieve the same resultant. Why code so much ?

    Search by metadata either way will fetch the required data anyway & quite quickly. The language-relevant tags' display then becomes more cosmetics than logic.

    Basically the problem situation precipitates to --> (1) Tag content in different languages   (2) When searching via a language locates any content - do not display languages other than the User's language [ or rather the language being searched by ;) ] Should be not too much headache to code that. But anyway - sorry .. I forgot - you were actually looking for the interaction between Trajan's 'solution' and the Elgg Core code areas. I might be distracting the issue.. 


  • Hi DhrupDeScoop,

    I'll follow your solution. To filter and display tags depending on the user's language, I can use plugin hook of ('search', 'tag', ...). Right?

    Many thanks.