Skip to main content

Settings Guide

Language Code

In the extension documents, you will see the term "Language Code", which is the unique identifier for the subtitle language.

If you hover the mouse above a menu item in the "Subtitle Language" menu, the tooltip will shows the language code of the menu item.

The language code is generally in the format LanguageType-LanguageSubtype.LanguageVersion, the latter two sometimes can be omitted.

The following are some example language codes and their meanings:

Language CodeLanguage TypeLanguage SubtypeLanguage Version
enEnglish
en-usEnglishUS English
en-gbEnglishUK English
en.asrEnglishAuto generated
en.cc EnglishCC subtitle
zhChinese
zh-hansChineseSimplified Chinese
zh-hantChineseTraditional Chinese

In the extension setting option "Show Specified Languages", if you input some language codes in it, then only the corresponding menu items will be shown. For example, we want to show English and Chinese only:

en, en-us, en-gb, en.asr, en.cc, zh, zh-hans, zh-hant

You will see that you need to input in all possible language codes, and different websites have different preference language codes for the "Language Subtype" and the "Language Version". For example, Traditional Chinese is not zh-hant, but zh-tw or zh-hk.

If the * wildcard is supported, it can be abbreviated as en*, zh*. It is better to be default behavior, so the * can be omitted, to abbreviate it to zh, en.

That is, the term "Language Code" have two meanings, "pattern" and "literal".

  • The pattern en matches the literal which starts with en.
  • The pattern must matches the whole word, that is, the pattern e will not match the literal en.

Here are some examples:

PatternMatch Literal
enen, en-us, en.cc, en-us.cc
en-usen-us, en-us.cc
en.ccen.cc
en-us.ccen-us.cc

Using Auto Selecting

The "Auto Selecting" feature allows you setup the menus with code, this feature can reduces manual operations.

The code is configured by the built-in plugin system, creating a new plugin, the type is "Auto Select (Standard Mode)".

When the following two conditions are satisfied, the "Auto Select" code will be executed:

  • All the "Subtitle Language" menus are closed, no matter close by manual or passive.
  • The menus required to refresh, includes page reload and the layout related setting options has changed.

The code can be simple or complex. For convenience, let's start with the easiest example, and explain the format at last.

The following code examples use these sample videos:

VideoAvaiable Subtitle Languages
A1zh-hans, en
A2zh-hant, en
Ben

Implement requirements: Display two subtitle languages, Chinese as the first subtitle, English as the second subtitle, Simplified Chinese is preferred. If there is no original Chinese, then translate English to Chinese.

Example 1

Code:

[zh-hans, zh]
[en]

Result:

Video#1 Subtitle Language#1 Machine Translation#2 Subtitle Language#2 Machine Translation
A1zh-hansen
A2zh-hanten
Ben

As you can see, A1 and A2 match the requirements, but B selects English as the first subtitle. The requirements is use Chinese translation.

Example 2

Code:

[zh-hans, zh]
[en][zh-hans]
[en]

In line 2, the bracket part [zh-hans], it means setup the "Machine Translation" menu.

Result:

Video#1 Subtitle Language#1 Machine Translation#2 Subtitle Language#2 Machine Translation
A1zh-hansenzh-hans
A2zh-hantenzh-hans
Benzh-hansen

As you can see, B matches the requirements, but A1 and A2 select Chinese twice, original and transation, because the first two lines both match successfully.

Example 3

Code:

[zh-hans, zh][][][1]
[en][zh-hans][][1]
[en][][][2]

The [1] and [2] at the end of line restricts the subtitle index.

Result:

Video#1 Subtitle Language#1 Machine Translation#2 Subtitle Language#2 Machine Translation
A1zh-hansen
A2zh-hanten
Benzh-hansen

All the videos match the requirements.

Code Format

The format is [SubtitleLanguage][MachineTranslation][ThemeStyle][Index]:

  • One menu corresponds to one bracket.
  • Multiple values can be separated by commas.
  • The index value 0 means no restriction.
  • The consecutive [] can be omitted.

That is, you can setup all the menus, for example, the code [en][zh-hans][Chinese Learning], which means:

  1. [en] Original language is English.
  2. [zh-hans] Translate original language to Chinese.
  3. [Chinese Learning] Apply "Chinese Learning" theme style.

If a line format is invalid, that line will be ignored, so you can use # to comment out a line. for example:

# Temporarily ignore a line of code.
#[en]

If a bracket value does not match, then the entire line treats as fail, and continue execute the code from the next line. Each line will be executed only once. If a line matches successfully, the next subtitle will execute from the next line.

# The following line will always fail, because the index always starts from 1.
[en][][][2]
[zh][][][1]

There are several variables:

  • LAST The last selected value.
  • CLOSE Setup to close。
  • SKIP Equals to LAST and CLOSE combination。

Code:

# Except for the "Subtitle Language" menu, the other menus are setup to close.
[zh][CLOSE][CLOSE]
# The following lines are exactly equal
[zh]
[zh][][][]
[zh][SKIP][SKIP]
[zh][LAST, CLOSE][LAST, CLOSE]

Notes

  • The code input to the "Subtitle Language" menu and the "Machine Translation" menu is pattern, see the "Language Code" section at the top of this page. The code input to the "Theme Style" menu is literal, which need to match exactly.
  • The variable LAST means "last selected value", the menus switched by passive will not be saved as the "last selected value", until you manually change any one of them.