XUnity.AutoTranslator icon indicating copy to clipboard operation
XUnity.AutoTranslator copied to clipboard

Regular expressions - range.

Open Loli-Kyn opened this issue 1 year ago • 5 comments

Briefly: I want a particular translation to apply to a particular number

Detail: Almost every word can have a plural applied to it. This changes the ending. There are usually two variants “Day”, “Days”. In English, usually only an “S” is added at the end of the word. (I'm not very good at English and I don't know all the subtleties yet). But in Russian there can be several endings depending on the dependent word. “1 день” “2 дня” ”5 дней” What I want to do: Let's say in regular expressions there are digits from 1 to 20. I want to make a range of digits to which one of the given translations will be applied.

For example The translation “A” will be applied to digit 1. To digits from 2→4 the translation “B” will be applied. To digits 5→20 the translation “D”. “А” = 1 デッキあと{{A}}枚必要 同カード{{B}}枚まで=We need another {{A}} card. Stack of cards {{B}} “В” = 2→4 デッキあと{{A}}枚必要 同カード{{B}}枚まで=Want more {{A}} cardS. Stack of cards {{B}} “Д” = 5→20 デッキあと{{A}}枚必要 同カード{{B}}枚まで=Need more {{A}} cardS. Stack of cards {{B}}

{{A}} and {{B}} is an included regular expression to the numbers so as not to duplicate the translation. You already know that.

I will duplicate the examples in Russian so that you can notice the difference in the endings. "А" = 1 デッキあと{{A}}枚必要 同カード{{B}}枚まで=Нужно еще {{A}} картА. Стак карт {{B}} "В" = 2→4 デッキあと{{A}}枚必要 同カード{{B}}枚まで=Нужно еще {{A}} картЫ. Стак карт {{B}} "Д" = 5→20 デッキあと{{A}}枚必要 同カード{{B}}枚まで=Нужно еще {{A}} карт. Стак карт {{B}}

Loli-Kyn avatar Dec 04 '24 07:12 Loli-Kyn

Those are substitutions, not regular expressions. Make 3 regexes, the last one is r:"^デッキあと([5-9]|1[0-9]|20)枚必要 同カード(\d+)枚まで$"=Need more $1 cards. Stack of cards $2.

Lmeks avatar Dec 04 '24 13:12 Lmeks

You might need to use \\ instead of \. idk

Lmeks avatar Dec 04 '24 14:12 Lmeks

Those are substitutions, not regular expressions. Make 3 regexes, the last one is r:"^デッキあと([5-9]|1[0-9]|20)枚必要 同カード(\d+)枚まで$"=Need more $1 cards. Stack of cards $2.

So if I want to apply this to all three options it would look like this?

"А" r:"^デッキあと([1]|1[0-9]|20)枚必要 同カード(\d+)枚まで$"=Нужна ещё $1 карта. Стак карт $2.`

"B" r:"^デッキあと([2-4]|1[0-9]|20)枚必要 同カード(\d+)枚まで$"=Нужно ещё $1 карты. Стак карт $2.`

"D" r:"^デッキあと([5-9]|1[0-9]|20)枚必要 同カード(\d+)枚まで$"=Нужно ещё $1 карт. Стак карт $2.`

Loli-Kyn avatar Dec 04 '24 15:12 Loli-Kyn

"А" r:"^デッキあと1枚必要 同カード(\d+)枚まで$"=Нужна ещё 1 карта. Стак карт $1.

"B" r:"^デッキあと([2-4])枚必要 同カード(\d+)枚まで$"=Нужно ещё $1 карты. Стак карт $2. There are several sites to test and learn regex online. XuA uses NET version.

Lmeks avatar Dec 04 '24 16:12 Lmeks

Detail: Almost every word can have a plural applied to it. This changes the ending. There are usually two variants “Day”, “Days”. In English, usually only an “S” is added at the end of the word. (I'm not very good at English and I don't know all the subtleties yet). But in Russian there can be several endings depending on the dependent word. “1 день” “2 дня” ”5 дней” What I want to do: Let's say in regular expressions there are digits from 1 to 20. I want to make a range of digits to which one of the given translations will be applied.

For example The translation “A” will be applied to digit 1. To digits from 2→4 the translation “B” will be applied. To digits 5→20 the translation “D”. “А” = 1 デッキあと{{A}}枚必要 同カード{{B}}枚まで=We need another {{A}} card. Stack of cards {{B}} “В” = 2→4 デッキあと{{A}}枚必要 同カード{{B}}枚まで=Want more {{A}} cardS. Stack of cards {{B}} “Д” = 5→20 デッキあと{{A}}枚必要 同カード{{B}}枚まで=Need more {{A}} cardS. Stack of cards {{B}}

{{A}} and {{B}} is an included regular expression to the numbers so as not to duplicate the translation. You already know that.

I will duplicate the examples in Russian so that you can notice the difference in the endings. "А" = 1 デッキあと{{A}}枚必要 同カード{{B}}枚まで=Нужно еще {{A}} картА. Стак карт {{B}} "В" = 2→4 デッキあと{{A}}枚必要 同カード{{B}}枚まで=Нужно еще {{A}} картЫ. Стак карт {{B}} "Д" = 5→20 デッキあと{{A}}枚必要 同カード{{B}}枚まで=Нужно еще {{A}} карт. Стак карт {{B}}

Thanks for your help. I don't understand how to use regular expression validation sites.

Loli-Kyn avatar Dec 04 '24 16:12 Loli-Kyn