Thanks @rednoah for logical reasoning. Test results for the different strings:
Code: Select all
{model.any{ id == it.id && it.lang =~ /swe/ } ? '.SWESUB' : { id == it.id && it.lang =~ /eng/ } ? '.ENGSUB' : null}
File with no embedded sub: ENGSUB
File with embedded eng sub: ENGSUB
File with embedded swe sub: ENGSUB
File with embedded swe + eng sub: ENGSUB
File with external eng sub: ENGSUB
File with external swe sub: SWESUB
File with external swe + eng sub: SWESUB
Code: Select all
{textLanguages =~ /swe/ ? '.SWESUB' : textLanguages =~ /eng/ ? '.ENGSUB' : null}
File with no embedded sub: - (nothing)
File with embedded eng sub: ENGSUB
File with embedded swe sub: SWESUB
File with embedded swe + eng sub: SWESUB
File with external eng sub: - (nothing)
File with external swe sub: - (nothing)
File with external swe + eng sub: - (nothing)
The first part of the code string with "model.any" is your work (the SWESUB part) =)