Skip to content

TinyMCE 7: getLanguage() fallback emits TinyMCE 3-style locale codes (e.g. zh-tw_utf8) #76

@mambax7

Description

@mambax7

Summary

XoopsFormTinymce7::getLanguage() (htdocs/class/xoopseditor/tinymce7/formtinymce.php) has two paths:

if (defined('_XOOPS_EDITOR_TINYMCE7_LANGUAGE')) {
    $this->language = constant('_XOOPS_EDITOR_TINYMCE7_LANGUAGE');   // fixed in #72
} else {
    $this->language = str_replace('_', '-', strtolower(_LANGCODE));
    if (strtolower(_CHARSET) === 'utf-8') {
        $this->language .= '_utf8';
    }
}

The fallback branch produces codes like zh-tw_utf8 — the lower-case hyphen form and the _utf8 suffix are TinyMCE 3 language-pack conventions. TinyMCE 7 language packs are case-sensitive with an underscore region (zh_TW.js, pt_BR.js, fr_FR.js, …) and have no _utf8 variants. So when a site has not defined _XOOPS_EDITOR_TINYMCE7_LANGUAGE, the computed code matches no TinyMCE 7 pack and the editor silently falls back to English.

#72 fixed the explicit-constant path only. This issue tracks the fallback.

Why it wasn't fixed inline

A correct fix requires decisions that shouldn't be guessed:

  1. The set of TinyMCE 7 locale codes XOOPS officially supports.
  2. A mapping from XOOPS _LANGCODE (per language) to those codes.
  3. The bundled TinyMCE 7 currently ships no language packs (htdocs/class/xoopseditor/tinymce7/js/tinymce/langs/ contains only README.md), so there is nothing in-tree to validate a mapping against.

Suggested direction

  • Decide/document the supported TinyMCE 7 locale list.
  • Replace the legacy transform with an explicit _LANGCODE → TinyMCE-7-code map (and drop the _utf8 suffix unconditionally — it is invalid for TinyMCE 7).
  • Add unit coverage for representative fallbacks (e.g. Traditional Chinese → zh_TW).

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions