Fixer.io: is there any way to get the currency description from a symbol? - currency

I am implementing an app using the Fixer.io API.
I wanted to retrieve the following:
currency description from a symbol (e.g. from EUR get EURO)
currency icon from a symbol
Is there any way to do so?
EDIT:
To obtain the description I am thinking of using the native iOS class nslocale:
https://developer.apple.com/documentation/foundation/nslocale/1642814-currencysymbol

There's a display name in the Supported Symbols Endpoint:
{
"success": true,
"symbols": {
"AED": "United Arab Emirates Dirham",
"AFN": "Afghan Afghani",
"ALL": "Albanian Lek",
"AMD": "Armenian Dram",
[...]
}
}
If you want to get the display name in another language, you can also use the java.util.Currency which has a method for names in local languages.
Or you can also give a try to the Java API for Fixer.io:
https://github.com/lico/jFixer
See also Fixer.io documentation:
https://fixer.io/documentation#supportedsymbols

Related

Convert restId to the entryId with calling translateExchangeIds?

As a followup to Converting restId format type to old Outlook HexEntryId type :
Since user2250152's excellent answer indicates that I have to do some programming myself, I was wondering:
Can I also do the conversion for the restId to the entryId myself?
That would save a call to translateExchangeIds.
Example data from the translateExchangeIds call:
"sourceId": "AAMkADI2ZGIwY2FlLTA1NDQtNGFhYi1hNDJmLWEyMGJhZWU5NmM2YgBGAAAAAACrxyqss0H-T5iGuqwSXncoBwB1kc8DNbIxRK3H-NcbpuL8AAAAAAENAAB1kc8DNbIxRK3H-NcbpuL8AAKHvUXcAAA="
"targetId": "AAAAAKvHKqyzQf9PmIa6rBJedygHAHWRzwM1sjFErcf81xum4vwAAAAAAQ0AAHWRzwM1sjFErcf81xum4vwAAoe9RdwAAA2"
"sourceId": "AAMkADI2ZGIwY2FlLTA1NDQtNGFhYi1hNDJmLWEyMGJhZWU5NmM2YgBGAAAAAACrxyqss0H-T5iGuqwSXncoBwB1kc8DNbIxRK3H-NcbpuL8AAAAAAENAABV1BT8PvI4S78XiwEQP4DVAATuyF7bAAA="
"targetId": "AAAAAKvHKqyzQf9PmIa6rBJedygHAHWRzwM1sjFErcf81xum4vwAAAAAAQ0AAFXUFPw-8jhLvxeLARA_gNUABO7IXtsAAA2"
"sourceId": "AAMkADI2ZGIwY2FlLTA1NDQtNGFhYi1hNDJmLWEyMGJhZWU5NmM2YgBGAAAAAACrxyqss0H-T5iGuqwSXncoBwB1kc8DNbIxRK3H-NcbpuL8AAAAAAENAAB1kc8DNbIxRK3H-NcbpuL8AAJ2Kv4fAAA="
"targetId": "AAAAAKvHKqyzQf9PmIa6rBJedygHAHWRzwM1sjFErcf81xum4vwAAAAAAQ0AAHWRzwM1sjFErcf81xum4vwAAnYq_h8AAA2"
EWS and Graph/rest Id's (which are just a base64URL safe version of the ewsId) contain the EntryId + some flags that tell the backend how to open the item. Microsoft don't document the format because they consider it opaque and subject to change. So you can do it yourself but it won't be supported if you convert both of the values to Hex and work backwards you'll see what i means eg
0003240032366462306361652d303534342d346161622d613432662d61323062616565393663366200460000000000abc72aacb341fe4f9886baac125e772807007591cf0335b23144adc7f8d71ba6e2fc00000000010d00007591cf0335b23144adc7f8d71ba6e2fc0002762afe1f0000
00000000abc72aacb341ff4f9886baac125e772807007591cf0335b23144adc7fcd71ba6e2fc00000000010d00007591cf0335b23144adc7fcd71ba6e2fc0002762afe1f00000d

Google Cloud Vision to detect only one language

Is there any way to specify the language that we need to extract from an image.
for example: I have an image that contains arabic+ french characters and the API returns a mixed text , is there a way to extract only french characters
You can use languageHints inside an imageContext request seting it to 'fr' for example:
"requests": [
{
"imageContext": {
"languageHints": [
"fr"
]
You can test it here

globalize numbers and currency: en-IN/INR format not working as expected

I have two methods i'm trying to write using globalize. One to format Numbers and one to format Currency.
function currencyFormatter(value, locale, fieldDefinition) {
var formatter = Globalize('en').currencyFormatter( 'INR' )
return formatter( value )
}
function numberFormatter(value, locale, fieldDefinition){
var formatter = Globalize('en').numberFormatter()
return formatter( value )
}
When I use the 'en' locale with 'INR' currency code for currencyFormatter or 'en' for numberFormatter i'm expecting to see something like ₹12,34,567.89 however what i get in both cases is something like ₹1,234,567.89 (minus currency symbol for number). I looked inside my node_modules folder cldr-data/main/en-IN/numbers.json and found this:
"percentFormats-numberSystem-latn": {
"standard": "#,##,##0%"
},
"currencyFormats-numberSystem-latn": {
"currencySpacing": {
"beforeCurrency": {
"currencyMatch": "[:^S:]",
"surroundingMatch": "[:digit:]",
"insertBetween": " "
},
"afterCurrency": {
"currencyMatch": "[:^S:]",
"surroundingMatch": "[:digit:]",
"insertBetween": " "
}
},
"standard": "¤ #,##,##0.00",
"accounting": "¤#,##0.00;(¤#,##0.00)",
I also went to CLDR website and dug up what i believe is the format file (en-IN.xml) and found this:
<rulesetGrouping type="OrdinalRules">
<ruleset type="digits-ordinal">
<rbnfrule value="-x">−→→;</rbnfrule>
<rbnfrule value="0">=#,##0=$(ordinal,one{st}two{nd}few{rd}other{th})$;</rbnfrule>
</ruleset>
</rulesetGrouping>
Both of these support the results we are getting are correct and our assumptions on what we expect are wrong. However, if you look out on the internet there are many reputable sites that say our assumptions are correct and the results are incorrect.
This leaves me in a state of not knowing what to do. Who's right? Can you help us to answer this question?
Also, is there a way to "overwrite" the default format if for whatever reason we wanted to change it?
You should use en-IN for English as spoken in India, i.e., Globalize('en-IN').

Tackle Localization with Graphql

In a json file, I have some fields that have a list of dictionaries with the locale and the translated text:
description_localized: [
{
locale: "en-UK",
value: "Read along"
},
{
locale: "de-DE",
value: "Lesen und"
},
{
locale: "fr-FR",
value: "Lis avec"
},
]
There are other fields where there are two keys in the value key:
path_localized: [
{
locale: "de-DE",
value: "{"identifier"=>"", "value"=>"http://path_6987.path"}"
},
{
locale: "es-ES",
value: "{"identifier"=>"", "value"=>"http://path_4685.path"}"
},
I already created a schema that grabs these fields, but instead of pulling the entire dictionary, on Graphql, I will need to be able to make a query where I only specify the language-locale I want (e.g. fr-FR) and that would only fetch the translated value for that one language (fr-FR). I don't want to get an array of all localized languages as this will be very taxing and will take longer to load per query.
Does anyone have any ideas on how I could accomplish this? Maybe through a resolver where I pass in the language as a parameter? But where would the languages be defined? I may need to clean this but we have an assortment of locale definitions: en_UK, en-UK, UK, en_UK_CO... Also, if the queried language is not found, how could I define a fallback?
Any guidance would be appreciated.
Thanks!
What stack are you working on, Node.js? If so, you can find a localization example here: https://github.com/kriasoft/nodejs-api-starter ..it uses "i18next" module to detect user's language, fallback to default language etc. then you can pass "lng" string as a context variable and use that inside of your "resolve()" methods. See src/app.js, src/Context.js.

How can I get the FULL list of slack emoji through API?

I am using the slack API to get the full list of emoji, so that when I get a message, I will just replace :squirrel: with the icon.
The method https://slack.com/api/emoji.list works like a charm, but returns 30 icons only. I think this is correct since in the documentation page (https://api.slack.com/methods/emoji.list) they say:
This method lists the custom emoji for a team.
Fair enough, but how can I get the full list of the associations icon-name / icon URL ?
I finally managed to get all the icons and to use them and I post here the solution for anyone that would like to use do similar:
First of all, I got the Slack Custom Emoji through this slack URL
Since at step 1 we get only Custom Emojis, it is useful to know that slack uses standard emoji defined in unicode characters, mapped through custom handles like :smiley: or :horse:. The good thing is that we can find, linked through slack page a link to a JSON object with all the emoji mappings. This file is HUGE, but has everything we need.
In the file you'll find an array of javascript object like the one below:
{
"name":"SMILING FACE WITH OPEN MOUTH",
"unified":"1F603",
"variations":[],
"docomo":"E6F0",
"au":"E471",
"softbank":"E057",
"google":"FE330",
"image":"1f603.png",
"sheet_x":26,
"sheet_y":18,"
short_name":"smiley",
"short_names":["smiley"],
"text":":)",
"texts":["=)","=-)"],
"category":"People",
"sort_order":5,
"has_img_apple":true,
"has_img_google":true,
"has_img_twitter":true,
"has_img_emojione":true
}
I used the following information:
shortnames are the names that are used in slack (you'll need to turn smiley into :smiley: )
unified is the unicode character to use (to use it directly in an HTML page you'll need to add &#x so in this case you'll have to use 😃 which is rendered 😃
Using this information you will be able to create a slack-to-html function to decode emojis and display them wherever you want
Not entirely sure if this is what you are looking for, but if it's just about mapping images to slack-style names, this is a pretty good library:
https://github.com/iamcal/emoji-data
So, building on the example in their README:
The emoji with the Slack style short name point_uphas the hex value 261d, and can thus be found here: https://github.com/iamcal/emoji-data/blob/master/img-apple-160/261d.png
(Apple, because the default slack emoji are the apple emoji)
Just extending on #Luca's awesome solution, I've created a shortnames => html unicode javascript dictionary...
Download: Slack emoticons to unicode html mapping.
Generated - 17th August 2018 from the source https://raw.githubusercontent.com/iamcal/emoji-data/master/emoji.json
Example:
{
"+1": "👍",
"-1": "👎",
"100": "💯",
"1234": "🔢",
"8ball": "🎱",
"ab": "🆎",
"abc": "🔤",
"abcd": "🔡",
"accept": "🉑",
...
"zebra_face": "🦓",
"zipper_mouth_face": "🤐",
"zombie": "🧟",
"zzz": "💤"
}
Which becomes...
{ "+1": "👍", "-1": "👎", "100": "💯",
"1234": "🔢", "8ball": "🎱", "ab": "🆎",
"abc": "🔤", "abcd": "🔡", "accept": "🉑",
... "zebra_face": "🦓", "zipper_mouth_face": "🤐",
"zombie": "🧟", "zzz": "💤" }
As far as I know, there is no API endpoint or comprehensive list of supported emoji/keywords available. I was able to grab the full set (including custom emoji for the workspace) by inspecting the Slack emoji picker using React Developer Tools (Chrome extension).
Here's an example (JSON):
...
{
"name": "beers",
"unicode": "1f37b",
"id": "E1f37b",
"keywords": ["bar", "beer", "clink", "drink", "mug", "ale", "food"]
},
{
"name": "baby_bottle",
"unicode": "1f37c",
"id": "E1f37c",
"keywords": ["baby", "bottle", "drink", "milk", "infant"]
},
{
"name": "knife_fork_plate",
"unicode": "1f37d-fe0f",
"id": "E1f37d-fe0f",
"keywords": ["cooking", "fork", "knife", "plate"]
},
{
"name": "champagne",
"unicode": "1f37e",
"id": "E1f37e",
"keywords": ["bar", "bottle", "cork", "drink", "popping"]
},
{ "name": "popcorn", "unicode": "1f37f", "id": "E1f37f", "keywords": [] },
...
Full dump (as of 12/20/2020, excluding custom emoji): https://gist.github.com/impressiver/87b5b9682d935efba8936898fbfe1919
Since it seemed impossible to find a complete and up-to-date source for these emoji names I came up with this browser console script. Just let it run in Slack and when it finishes it will download a full emoji.json. At time of writing it contains 2485 entries.
https://gist.github.com/8461e125072c2806301403a4e1eca891
This looks like this:
{
"+1": "https://a.slack-edge.com/production-standard-emoji-assets/13.0/google-medium/1f44d#2x.png",
"+1::skin-tone-2": "https://a.slack-edge.com/production-standard-emoji-assets/13.0/google-medium/1f44d-1f3fb#2x.png",
"+1::skin-tone-3": "https://a.slack-edge.com/production-standard-emoji-assets/13.0/google-medium/1f44d-1f3fc#2x.png",
"+1::skin-tone-4": "https://a.slack-edge.com/production-standard-emoji-assets/13.0/google-medium/1f44d-1f3fd#2x.png",
If you want the actual emoji instead of the image you can parse that out of the image file name, e.g. 1f44d-1f3fd#2x.png is "\u1f44d\u1f3fd".

Resources