stylus icon indicating copy to clipboard operation
stylus copied to clipboard

feature request; localization support for @name, @description, and, @var

Open tiansh opened this issue 7 years ago • 5 comments

Adding localization support for @name, @description, and @var should be very useful, imo.

For name and description, i would suggest do it similar way as what userscripts done.

For @var, i would suggest when localized @var is given (e.g. @var:zh), the un-localized @var with same name was just ignored. This may be useful for setting different default font for users in different languages (maybe).

tiansh avatar Apr 26 '18 03:04 tiansh

While @key:lang syntax works for name and description, it won't work for variables in styles that have huge variables (GitHub Dark, for example), also duplication of the declarations will make it harder to edit the variables in any style. Hence I think we need a different syntax for variables:

@var select font-bkgd 'Font background' {
  "near_black:Near Black": "#111111",
  "near_white:Near White": "#eeeeee"
}
@translate:zh_CN {
  "Font background": "....",
  "Near Black": "....",
  "Near White: "...."
}

@eight04, @Mottie, @RaitaroH, thoughts?

tophf avatar Apr 27 '18 07:04 tophf

Yes, I like that idea - target the translations directly.

Mottie avatar Apr 27 '18 13:04 Mottie

Less places you need to edit the better.

RaitaroH avatar Apr 27 '18 14:04 RaitaroH

A problem is that if the en label is changed, all other keys of @translate:XX have to be modified accordingly. Imagine if you want to change en label for following style:

@var color font-color "Font color" #000000
@translate:AA {
  "Font color": "..."
}
@translate:BB {
  "Font color": "..."
}
...
@translate:ZZ {
  "Font color": "..."
}

A good point is that all translated strings of the same locale are located at the same place.

If the translation is defined through @var:XX, there is a problem that sometime the label is used as the key of @var select option:

@var select font-color "Font color" {
  "Near white": "#eeeeee",
  "Near black": "#111111"
}
@var:zh select font-color "........." {
  "xxxxxxxx": "#eeeeee",
  "yyyyyyyy": "#111111"
}

Note that we have to map the translation to their original keys (xxxxxxxx -> Near white and yyyyyyyy -> Near black) or users would lose their settings after switching the locale.

A good point is that it is possible to provide different settings for each locale. It could be shorter if we dont need localizable values:

@var select font-color "Font color" {
  "Near white": "#eeeeee",
  "Near black": "#111111"
}
@translate zh "........" ["xxxxxxxx", "yyyyyyyy"]

But it looks confusing to me.

eight04 avatar Apr 27 '18 16:04 eight04

Why don't we target the variable label since it won't be as likely to be changed; then with a select, we only target the label & keys:

@var select font-color "Font color" {
  "Near white": "#eeeeee",
  "Near black": "#111111"
}
@translate:AA {
  "font-color": ["...", "...", "..."] // Font color, near white, near black
}
...
@translate:ZZ {
  "font-color": ["...", "...", "..."] // Font color, near white, near black
}

@var color bkgd-color "Background color" #000000
@translate:AA {
  "bkgd-color": "..."
}
...
@translate:ZZ {
  "bkgd-color": "..."
}

Mottie avatar Jul 15 '18 15:07 Mottie