Closed octfx closed 2 years ago
@octfx thanks for the question
Have you tried, using the +lang selector as a separate parameter? Disclaimer: Unfortunately, I have never used the cool language filter feature. However, referencing my basic knowlege of the code and the ask-syntax, I would deduct since "|" in wiki code is used to separate operators in the ask query, you should/could add the +lang as separate item in the query table.
In other words, could you please try the following and return with the result:
mw.smw.ask( { '[[-Has subobject::Example]][[Typ::+]]', '?Example=renamed_de', '+lang=de' } )
Oh interesting!
This does indeed seem to fix the problem. Many thanks 😊
Alternatively I've found that table.concat( { ... } ,'|' )
works for this aswell (but it breaks some other queries)
splendid. :)
However I am a little flabbergasted that table.concat( { ... } ,'|' )
works. Please don't ask my why. I would not recomment using it.
Another thing: some people (me included) sometimes like to use lua tables in the same way as an associative array, especially whan adding query parameters. An example can be found in the documentation and would look like this:
query.mainlabel = 'origin'
query.limit = 10
BUT! Please dont try using this method for the language paramter. Something like the following will most probably not work and possible leed to unexpected behaviour:
query['+lang'] = 'de'
the reason is that lua does not maintain the order of elements in tables indexed by non-numerical values. and since the +lang
parameter needs to be positional as it references the selector preceeding it, this will leed to unexpected (and inconsistent) behaviour.
Yeah I've learned not using table.concat( { ... } ,'|' )
the hard way.
Right now I'm building my query as follows:
local smwData = mw.smw.ask( {
'[[-Has subobject::' .. page .. ']][[Typ::+]]',
'?Aus Spieldaten#-=from_gamedata',
'[...]'
'?Komponentenklasse=class', '+lang=' .. common.getLocaleForPage(),
'?Komponentenklasse=class_de',
'+lang=de',
'?Typ=type', '+lang=' .. common.getLocaleForPage(),
'?Typ=type_de', '+lang=de',
'?UUID#-=uuid',
'[...]'
'sort=Komponentenklasse,Typ,Maximalgröße,Anzahl',
'order=asc,asc,asc,asc',
} )
As this works, I'm guessing that the order is preserved.
Thanks again!
Setup and configuration
Issue
Using a language filter on a renamed column results in the language filter being appended to the renamed name.
Examples:
Produces correct results, a table of tables containing only the german text for
Column
.Produces incorrect results:
Am I calling
mw.smw.ask
wrong?