类 CompositeDictI18nProvider

java.lang.Object
cn.silwings.dicti18n.provider.CompositeDictI18nProvider
所有已实现的接口:
DictI18nProvider

public class CompositeDictI18nProvider extends Object implements DictI18nProvider
A multi-dictionary loader combination provider that aggregates multiple DictI18nLoader according to the configuration order to achieve internationalization parsing and language degradation support for dictionary text.
  • 字段详细资料

  • 构造器详细资料

    • CompositeDictI18nProvider

      public CompositeDictI18nProvider(DictLoaderSorter sorter)
      Constructors, receive sequencers and configuration items, initialize loader lists.
      参数:
      sorter - A loader sequencer that controls the order in which the loader is executed
  • 方法详细资料

    • getText

      public Optional<String> getText(String language, String defaultLanguage, String dictName, String code)
      Retrieve internationalized copy (dictionary text) for the specified language. Supports language fallback lookup (e.g., zh-CN -> zh) and also supports default language and fallback language configuration.

      The search order is as follows (in the sequence of loaders): 1. Search from the fallback chain of the current language (e.g., en-US -> en) 2. If not found, attempt to search using the configured default language (defaultLang). 3. If still not found, try looking it up with the special fallback key ("").

      Once any step in a loader successfully finds a result, it immediately returns that result.

      指定者:
      getText 在接口中 DictI18nProvider
      参数:
      language - User language, such as "en-US", "zh-CN"
      defaultLanguage - Default language, such as "en-US", "zh-CN"
      dictName - Dictionary name, such as "order_status"
      code - Dictionary keys, such as "pending"
      返回:
      The dictionary description in the corresponding language, or returns Optional.empty() if not found.
    • resolveKey

      public String resolveKey(String dictName, String code)
      Construct the dictionary key name for loader queries, typically formed by concatenating the dictionary name with the code.

      Example: dictName = "order_status", code = "pending", return "order_status.pending"

      参数:
      dictName - dictionary name
      code - Dictionary key-value, such as "pending"
      返回:
      spliced key name