Talk:Q4917

From Wikidata
Jump to navigation Jump to search

Unit symbol[edit]

It really isn't helpful to replace "English" with "multiple languages" for a unit symbol. If you are working in a particular language and have a quantity in US dollars and want to display a unit symbol, then testing your language code against "mul" doesn't give a match, because "multiple languages" isn't a language. If we stick with "en" for the language of the symbol, then all languages will fallback to it in any case, unless there's an entry for a particular language which doesn't use the $ symbol. That's surely exactly how we need to set up the statements for unit symbol (P5061): the $ symbol as English; plus any other symbols that exist in other languages/scripts that do not use the $ symbol (if any). Otherwise, what's the point of having language fallback? --RexxS (talk) 21:04, 22 September 2019 (UTC)[reply]

@RexxS: In many places I've seen, for units formatting "mul" language is used as a "fallback" rather than "en". I have no problems if you will add en:$ as an additional statement here --Ghuron (talk) 03:39, 23 September 2019 (UTC)[reply]
@Ghuron: The property unit symbol (P5061) has type monolingual text because it is intended that each language can have its own symbol associated with its script/spelling as needed. The language fallback mechanism is implemented in the Scribunto software - see mw:Extension:Scribunto/Lua reference manual #mw.language.getFallbacksFor - and there is no fallback to "mul" from any language, so I'm afraid you're mistaken in thinking that you've seen it. All languages eventually fallback to English and it does not make sense to remove that from a property of type monolingual text, which expressly requires a valid language code. Using "mul" doesn't give any more info, but it's harmless as long as you don't remove "en". --RexxS (talk) 13:01, 23 September 2019 (UTC)[reply]
@RexxS: We happens to discuss this on the talk page for US Dollar, which almost universally represented as $. The language fallback mechanism applies to labels/descriptions of items, not values of P5061 for units. And no, I'm not mistaken, my edit from June 10 was caused by this discussion (its in Russian, but google translate do the trick) --Ghuron (talk) 13:19, 23 September 2019 (UTC)[reply]
@Ghuron: That discussion you link to talks about the duplication of unit symbol and unit name, and says nothing about language fallbacks. Are you sure you linked the right thread? Of course the language fallback system applies to all entities that can be manipulated in Lua - here's a snippet of code illustrating how you can implement the fallback table to get the best match for a item of monolingual text like P5061:
				local unitsymbols = mw.wikibase.getAllStatements(unitqid, "P5061")
				-- construct fallback table
				local fbtbl = mw.language.getFallbacksFor( args.lang )
				table.insert( fbtbl, 1, args.lang )
				local found = false
				for idx1, symbol in ipairs(unitsymbols) do
					for idx2, fblang in ipairs(fbtbl) do
						if symbol.mainsnak.datavalue.value.language == fblang then
							usym = symbol.mainsnak.datavalue.value.text
							found = true
							break
						end
					if found then break end
					end -- loop through fallback table
				end -- loop through values of P5061
				if found then usep, unit = " ", usym end
That, of course, fails if 'mul' is the only "language" entry for a piece of monolingual text like the value of P5061, because mw.language.getFallbacksFor never returns 'mul' as a value in its list. --RexxS (talk) 14:49, 23 September 2019 (UTC)[reply]
@RexxS: I've temporary removed "mul" value and take a screenshot of ru:Тим, Доминик. Please compare "призовые" value in infobox. So, yes, there is a duplication of currency in infobox label and infobox value, but no, the discussion is not about that, but about доллар США (ru-label of this element) vs $ And yes, you can write code, that implements fallback logic for units, but no, all languages eventually fallback to English is not 100% correct statement. I'm not saying your logic is incorrect (I do not have opinion here), maybe we should go and fix russian infobox modules and (dozen others in downstream wikis). But until we've fixed them, I believe it would be wise to keep "mul" value here --Ghuron (talk) 09:16, 24 September 2019 (UTC)[reply]
@Ghuron: Okay, that makes sense.
I'm afraid you're still wrong about "no, all languages eventually fallback to English is not 100% correct statement", though. I've got code that I use as a demo for when I'm mentoring Google Code-In that shows the fallback sequence for every language supported. You can see the fallbacks for every language supported by MediaWiki at en:Module talk:Sandbox/RexxS/GCI09 and you'll observe that every single one of the 443 languages falls back to English as its last fallback. That's why it's important to have an English value for monolingual text (as well as labels, etc.) because it guarantees that every reader will get something rather than a null value.
As I said, I can see no problem with adding a value for 'multiple languages' as long as you don't remove the English value. Cheers --RexxS (talk) 16:40, 24 September 2019 (UTC)[reply]