Index of every page on this site: llms.txt
All skills
jame581 avatar

/localization

@426e8ab
by Jan Mesarčjame581/godotprompter979 stars
63
Run it yourself

Use when implementing localization (i18n/l10n) — TranslationServer, CSV/PO translation files, locale switching, RTL support, and pluralization in Godot 4.3+

Use this Skill: https://skilld.dev/gh/jame581/godotprompter/localization

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesrtl-support.md

≈979 tokens on demand. Your agent reads this file only when SKILL.md points to it.

← Back to SKILL.md

Right-to-Left (RTL) Support

For Arabic, Hebrew, Persian, and other RTL languages.

Enabling RTL

# On any Control node
control.layout_direction = Control.LAYOUT_DIRECTION_RTL

# Or set globally in Project Settings:
# Internationalization → Rendering → Root Node Layout Direction → Right-to-Left
// On any Control node — note the enum is nested, not a flat constant.
control.LayoutDirection = Control.LayoutDirectionEnum.Rtl;

// Usually better than hard-coding Rtl: derive it from the app's own locale (Godot 4.4+;
// on 4.3 use LayoutDirectionEnum.Locale, which 4.4+ keeps as a deprecated alias).
control.LayoutDirection = Control.LayoutDirectionEnum.ApplicationLocale;

// The Project Settings route is identical:
// Internationalization → Rendering → Root Node Layout Direction → Right-to-Left

Per-Control Settings

Property Purpose
layout_direction INHERITED, APPLICATION_LOCALE (auto, from the loaded translation), LTR, RTL, SYSTEM_LOCALE (auto, from the OS). APPLICATION_LOCALE and SYSTEM_LOCALE are 4.4+; 4.3 has LOCALE, which 4.4+ keeps as a deprecated alias for APPLICATION_LOCALE
text_direction On Label/RichTextLabel: override text direction
structured_text_type Handles special structures (URLs, paths, email) that shouldn't fully reverse

RichTextLabel BBCode for Mixed Direction

# Isolate a number or URL as LTR inside RTL text ([lri] … [pdi]; there is no [ltr] tag)
rich_text.text = "النتيجة: [lri]100/200[pdi]"
// Same BBCode from C# — it is markup in the string, not an API difference.
// BbcodeEnabled must be true or the tag renders literally.
richText.BbcodeEnabled = true;
richText.Text = "النتيجة: [lri]100/200[pdi]";

Reacting to a locale change

TranslationServer has no signals — there is nothing to connect to. Godot delivers Node.NOTIFICATION_TRANSLATION_CHANGED (MainLoop has a constant of the same name) instead, so override _notification and re-apply layout from there. Because you never subscribed, there is no handler to disconnect and nothing to leak when the scene is freed.

# locale_aware_panel.gd — flip layout direction on locale change.
extends Control

func _ready() -> void:
    _apply_layout_for_locale()


func _notification(what: int) -> void:
    if what == NOTIFICATION_TRANSLATION_CHANGED:
        _apply_layout_for_locale()


func _apply_layout_for_locale() -> void:
    var locale := TranslationServer.get_locale()
    var is_rtl := TextServerManager.get_primary_interface().is_locale_right_to_left(locale)
    layout_direction = Control.LAYOUT_DIRECTION_RTL if is_rtl else Control.LAYOUT_DIRECTION_LTR
// LocaleAwarePanel.cs — flip layout direction on locale change.
using Godot;

public partial class LocaleAwarePanel : Control
{
    public override void _Ready() => ApplyLayoutForLocale();

    // TranslationServer exposes NO signals — react to the engine notification instead.
    // Nothing to subscribe to means nothing to unsubscribe from, so there is no handler
    // to leak when the scene is freed.
    public override void _Notification(int what)
    {
        if (what == NotificationTranslationChanged)
            ApplyLayoutForLocale();
    }

    private void ApplyLayoutForLocale()
    {
        string locale = TranslationServer.Singleton.GetLocale();
        bool isRtl = TextServerManager.GetPrimaryInterface().IsLocaleRightToLeft(locale);
        LayoutDirection = isRtl
            ? Control.LayoutDirectionEnum.Rtl
            : Control.LayoutDirectionEnum.Ltr;
    }
}

Font Requirements

RTL scripts need fonts covering the relevant Unicode ranges — Godot's default font doesn't cover Arabic/Hebrew. Import Noto Sans Arabic (or similar) and assign via Theme.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts7d3 checks · Risk SAFE
  • Gen Agent Trust Hub7d

    This skill is a comprehensive guide for implementing localization in Godot 4.3+. It covers core concepts, translation file formats (CSV and PO), runtime locale switching, RTL support, and pluralization. No security issues were detected.

  • Socket7d

    No alerts

  • Snyk7d

    Risk: LOW · No issues

Signed by skilld at 426e8ab. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 6 days ago.

Activeupdated last week

README badge

README badge for jame581/godotprompter/localization