1

The site uses a custom mod_menu. How do you call the native language title?

<?php

    $lang = JFactory::getLanguage();
    $lang_name = $lang->getName(); 

?>

    <?php echo $lang_name;?>

This returns: English (en-GB) or for Chinese: "中文(繁體.台灣)".

However - I want the native title which is "EN".

Or for Chinese the Native Title is "繁中".

1 Answer 1

1

try this :

  <?php
        $app             = JFactory::getApplication();
        $doc             = JFactory::getDocument();
        $this->language  = $doc->language;
        $lng=explode('-',$this->language);
        print(strtoupper($lng[0]));
    ?>
1
  • Thanks - I adapted it to as it was causing a php error: <?php $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $language = $doc->language; $lng=explode('-',$language); print(strtoupper($lng[0])); ?> However - this isn't pulling the native title - just the doc->language. So - it fails with the multi-linguial version. Eg Chinese 中文 becomes ZH.
    – iamrobert
    Mar 14, 2017 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.