Page MenuHomePhabricator

Api calls should specify language
Open, LowPublic3 Estimated Story Points

Description

Applies to parsedcomment for the watchlist api calls, tag display language, and probably something else that I'm missing

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
DannyS712 set the point value for this task to 3.
DannyS712 moved this task from Unsorted to Next on the User-DannyS712 board.

I guess this applies to all of the watchlist retrieval api calls, not just wikibase, but its clearest there
By default, the default language used is user, meaning to use the user's preferences
To account for any preferences being different across wikis, we should not override that if the uselang parameter is not set
I guess mw.util.getParamValue( 'uselang' ) can be used to check if its set

DannyS712 renamed this task from Wikibase api calls should specify language to Api calls should specify language.Feb 11 2021, 11:28 PM
DannyS712 updated the task description. (Show Details)

I guess this applies to all of the watchlist retrieval api calls, not just wikibase, but its clearest there
By default, the default language used is user, meaning to use the user's preferences
To account for any preferences being different across wikis, we should not override that if the uselang parameter is not set
I guess mw.util.getParamValue( 'uselang' ) can be used to check if its set

Except we already retrieve the labels for the wikibase items in the currently used language (mw.config.get( 'wgUserLanguage' )) and its unlikely that users will have wikis shown in two different languages...
@IKhitron thoughts? I know you were saying something about viewing metawiki in a language different from the languages you view the other wikis with. We have the following informatio available

  • the current page view language, from mw.config.get( 'wgUserLanguage' )
  • we can add a check for whether this is specified explicitely in a uselang parameter, or is based on the users preferences, via mw.util.getParamValue
  • for most things, the default language used is based on the users preferences on the foreign wiki, which uselang= should be able to override

As I already said, for my sake uselang is quite enough. Don't know what do you want achidve with this.

As I already said, for my sake uselang is quite enough. Don't know what do you want achidve with this.

I was asking since I believe you said you view some wikis with different languages set in your preferences.

Yes, I have all rtl wikis on Hebrew, ruwiki on Russion, and the rest on English. So?

Yes, I have all rtl wikis on Hebrew, ruwiki on Russion, and the rest on English. So?

So, I guess this is most clearly visible for the displayed text of the different tags.
Currently, tags should all be shown in the language you chose for that wiki (i.e. change tags for edits on hewiki are shown in Hebrew, change tags for edits on ruwiki are shown in Russian, and change tags for enwiki edits are shown in English).

If we say, always use the language specified in mw.config.get( 'wgUserLanguage' ), the change tags would all be shown in English (since you have that set for meta) or whatever you override uselang= with. My question is, for users that don't specify uselang=, should tag labels be shown according to their preferences on the foreign wiki (for your case, Hebrew or Russian) or the local wiki (English)?

If we always want to use the language of the current page view, regardless of whether its because of local preferences or uselang, its fairly easy. However, if we only want to override foreign wiki preferences when uselang is explicitely used, thats a bit trickier.

How can you use the language of local wiki? You do not know what is this language and can't recognize this.

How can you use the language of local wiki? You do not know what is this language and can't recognize this.

The default for api calls is to use the language of the preferences on the target wiki. We can override this to specify that a specific language be used.

I mean, how do you know which language you should use to override? How do you now that I prefer Hebrew without me saying this explicitly, for example by using uselang?

I mean, how do you know which language you should use to override? How do you now that I prefer Hebrew without me saying this explicitly, for example by using uselang?

mw.config.get( 'wgUserLanguage' ) returns the language that the user has set for their preferences locally (unless its overridden by uselang) (technically, it just returns the language of the context for the result, but that language is the one based on user preference, uselang overrides, and whatever the configuration default is for users with no preferences set)

On which wiki? If somebody turns on a computer, opens a browser, opens the GW page on Meta, you do not know what wiki does this user prefer to work on.

On which wiki? If somebody turns on a computer, opens a browser, opens the GW page on Meta, you do not know what wiki does this user prefer to work on.

Okay, I see where the confusion may be.
"local wiki" = wiki where Special:GlobalWatchlist is being viewed
"foreign wiki" = wiki with changes

By default, the api will fetch with the language being the virtual language user. If this is the case, the api will use the user preferences on the foreign wiki when fetching stuff for that foreign wiki - in your case, everything should be in Hebrew for hewiki, Russian for ruwiki, and English for others like eswiki

mw.config.get( 'wgUserLanguage' ) returns the language of the current page view. By default, this will be the user's preference on the local wiki, but it can be overridden with uselang=.

If we tell the api to use the language that we get from mw.config.get( 'wgUserLanguage' ), then uselang= will correctly override user preferences and force everything to be in that language, but even when uselang= is not set, all wikis will be fetched according to the language preferences on the local wiki.

It should be possible to decide to only override the default user if and only if the uselang= parameter is specified, and that is what I am proposing.

OK. So how is this different from the current state? It does show the wikidata labels on the Meta preferences language, or overrided by uselang, doesn't it?

OK. So how is this different from the current state? It does show the wikidata labels on the Meta preferences language, or overrided by uselang, doesn't it?

While wikidata labels are currently shown using mw.config.get( 'wgUserLanguage' ) always, since using the local preference isn't an option, you are correct.
However, this is about the language that should be used for other stuff, like automatic summaries from wikibase (when creating a new item, the summary in the database is wikibase-item-summary-wbeditentity-create-item and at run time, this is converted to, eg, "Created a new Item" (en) or "创建新项" (zh)) or tag descriptions. Currently, those all rely on the user preferences on foreign wikis, and thus cannot be overridden by uselang, and I was proposing that they do be overridden by uselang

But, on the other hand, how can you be sure that the user does not prefer the foreign language preferences. He set them to use these wikis, including reading the diffs and the history pages.

But, on the other hand, how can you be sure that the user does not prefer the foreign language preferences. He set them to use these wikis, including reading the diffs and the history pages.

So I was proposing to only ignore the foreign language preferences when uselang is explicitly chosen, since uselang is normally used to override language preferences

It will work better if you allow to make uselang language permanent in preferences, as I already suggested.