[DOCS] {lang} and {subt} subtitle language tag

All about user-defined episode / movie / file name format expressions
Locked
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

[DOCS] {lang} and {subt} subtitle language tag

Post by rednoah »

{lang} and {subt} can be used to add the language code to the file name. The subtitle language is auto-detected from the file name (e.g. .eng language suffix) or the text content of the subtitle file via statistical language identification.


2-letter language code

Format: Select all

{ '.' + lang.ISO2 }

Code: Select all

.nl
3-letter language code

Format: Select all

{ '.' + lang.ISO3 }

Code: Select all

.nld
3-letter language code (Bibliographic)

Format: Select all

{ '.' + lang.ISO3B }

Code: Select all

.dut
Language name

Format: Select all

{ '.' + lang.name }

Code: Select all

.Dutch


{subt} is a formatted String with leading . dot and ISO 639-2/B language code. {subt} will additionally match the subtitle type tag (e.g. forced, SDH, etc) from the original file name.

Format: Select all

{ subt }

Code: Select all

.eng.srt
.eng-forced.srt
.eng-HI.srt
.eng-CC.srt
.eng-SDH.srt


:!: {lang} and {subt} are defined only for subtitle files.

e.g.

Format: Select all

{ ny }{ subt }

Code: Select all

Avatar (2009).mkv
Avatar (2009).eng.srt
Avatar (2009).eng-forced.srt



Multiple Subtitles per Subtitles Language and Subtitle Tag

If you have multiple subtitles for the same language and tag, then {lang} and {subt} will generate the same file path for each file, and thus only allow one file per subtitle language and tag. If you want to keep multiple subtitles per subtitle language and tag, then you need to customize your format to yield a unique file path for each unique subtitle file.

Code: Select all

Subs/English_1.srt
Subs/English_2.srt
Subs/English_3.srt
e.g. match the trailing _1 pattern from the original file name:

Format: Select all

{ subt }{ fn.match(/[._-][0-9]$/) }
e.g. add {di} duplicate index to the file name:

Format: Select all

{ subt }{ dc > 1 ? '_' + di : null }
Alternatively, you can write your own custom code. See my multiple/duplicate subtitles naming scheme for one possible example that uses the {model} binding to add subtitle indices per language if needed.
:idea: Please read the FAQ and How to Request Help.
Locked