المساعدة في الترجمة/عرض التسميات بشكل صحيح

أحاول إنشاء مكون سمة يضيف تسطيرًا لشريط أدوات المؤلف.
أتمكن من جعله يعمل، وعنوان الزر يعمل، ولكن عند استخدامه يعود
[en.composer.underline_text]
وليس المتوقع
نص مثال
لقد كنت أدور في دوائر ولكنني غير قادر على معرفة السبب، هل لدى أي شخص فكرة عما أفتقده؟
شكرًا

api-setup.js

import { apiInitializer } from "discourse/lib/api";
import I18n from "I18n";
import { iconNode } from "discourse-common/lib/icon-library";

export default apiInitializer("0.11.1", (api) => {
  const currentLocale = I18n.currentLocale();

  I18n.translations[currentLocale].js.underline_button_title = settings.underline_button;
  I18n.translations[currentLocale].js.underline_text = settings.underline_text;

  api.onToolbarCreate((toolbar) => {
    const buttons = [
      {
        id: "underline_button",
        group: "fontStyles",
        icon: "underline",
        shortcut: "U",
        title: "underline_button_title",
        perform: (e) => e.applySurround("[u]", "[/u]", "underline_text"),
      },
    ];

    buttons.forEach((button) => toolbar.addButton(button));
  });

  api.decorateCookedElement(
    async (elem, helper) => {
      const id = helper ? `post_${helper.getModel().id}` : "composer";
      applyHighlight(elem, id);
    },
    { id: "wrap-mark" }
  );
});

settings.yml

underline_button:
  default: "Underline"
  description:
    en: Enter the text for the title of the button in the composer.
underline_text:
  default: "Example Text"
  description:
    en: Enter the placeholder text that appears in the composer after the user clicks the button.

Svg_icons:
  type: 'list'
  list_type: 'compact'
  default: 'underline'
  description:
    en: "Include FontAwesome 6 icon classes for each icon used in the list."

en.yml

en:
  js:
    underline_button_title: settings.underline_button
    underline_text: settings.underline_text

لماذا تقوم بإنشاء النصوص كإعدادات بدلاً من وضعها مباشرة في en.yml؟

أعتقد أن Composer Footnote Button مثال مفيد

3 إعجابات

شكراً لإرشادي في الاتجاه الصحيح

اتضح أن
I18n.translations[currentLocale].js.underline_text = settings.underline_text;
يجب أن يكون
I18n.translations[currentLocale].js.composer.underline_text = settings.underline_text;

3 إعجابات

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.