tomayac / wikipedia-tools-for-google-spreadsheets

Wikipedia Tools for Google Spreadsheets — Install:
https://gsuite.google.com/marketplace/app/wikipedia_and_wikidata_tools/595109124715?pann=cwsdp&hl=en
Apache License 2.0
144 stars 32 forks source link

=WIKITRANSLATE("en:Berlin", "xx") should not return the English title, but only xx title #48

Closed AramBakir closed 2 years ago

AramBakir commented 2 years ago

Problem

Hello, I have encountered a problem with WIKITRANSLATE function. Logically and programmatically, when we specify the target language codes in the second parameter (which is opt_targetLanguages), it should return only the targeted languages, not the first parameter language title (which is article). Let me show an example. Imagine we have only two cells one after one like this: Article title
Berlin
France
And, for example, when we change the first cell (which is Berlin) to =WIKITRANSLATE("en:Berlin", "ckb"), we get an error because the function return both en and ckb titles, but the second cell (which is France) blocks the other language to be printed while the function syntax is correct. As a result, we get an #REF! error in the Berlin cell as we see below. Article title
#REF!
France

Solution

The function should return only opt_targetLanguages language codes and the first parameter (article) should use it's argument as a reference only, not return anything. In the above example, we should use =WIKITRANSLATE("en:Berlin", "ckb") instead Berlin and see Language code Article title
ckb بەرلین
France
Another example code: Article title
=WIKITRANSLATE("en:Berlin", "ckb")
=WIKITRANSLATE("en:Berlin", "ar")
Result: Language code Article title
ckb بەرلین
ar برلين

As we can see, we use en:Berlin just as a reference and we don't need the English title. I hope you understand me and my examples. I really appreciate if you try to fix that problem. Thank you in advance!

tomayac commented 2 years ago

You do this via the INDEX() function. See this sheet for a demo:

=INDEX(WIKITRANSLATE(A1, "ab"), 0)