Sonos SMAPI: how to internationalize containers? - internationalization

I'm trying to get our Music Service's SMAPI validated with Sonos. Automated tests passed. I'm now getting what looks like the results of manual QA tests from the Sonos support.
In the "Browse" category, a test named "Is an english translation provided for all containers?" is marked as failed with the notice "Service is in German". We are structuring our music service content by means of hierarchical mediaCollections. Since we're a Germany-based company, the containers (essentially music genres) have german titles.
We'd be happy to provide english translations if need be, but I can't seem to find how I'm supposed to add these translations in the Sonos SMAPI Documentation.
Could anybody please point me into the right direction?

There are two options for localizing containers.
The first is to use the Accept-Language HTTP header which is sent on each request and have your server choose the correct language to return in the getMetadata response.
The second option is to use display types. For each container return a different displayType in the getMetadata response. Then in the presentation map file map the display type to a specific string id.
<DisplayType id="newRelease">
<Lines>
<Line stringId="NEW_RELEASE"/>
</Lines>
</DisplayType>
Then in the strings file you can provide multiple localizations for the NEW_RELEASE string and Sonos will do the work of choosing the correct localized string.

Related

How would you implement internationalisation for free-text?

Disclaimer: I couldn't come up with a better name for the question - but I'll try to explain what I'm trying to achieve.
Let's assume we have a client-server application with client-side internationalisation. At this moment it is out of the question to move all the internationalisation to the backend.
The backend service saves some tags in the database as strings. (e.g.: CAR)
The client of this service performs a GET, translates the tags and displays them in the view (e.g.: Car (en), Auto (es)).
Now we want to add some filters to a query based on the tags.
Everything works fine as long as we have a list of pre-defined tags that are mapped to the tags stored in database, but how would you implement a solution where a user can type in a text filter (in any language) and the backend to return the values matching with the "original" tag?
i.e.: type in auto, backend returns CAR.

Alternative to spring-mobile

I have a requirement where in all controllers I need to understand device type (desktop, mobile, tablet) and based on that I may need to send request to a different view. Right now, I have littered my controllers with duplicate code that does following:
Get User-Agent from HttpServletRequest
Find device type by matching User Agent string containing multiple pre-defined keywords in an array.
Use if/else statement to forward request to different view based on detected device type
To fix this I found out that spring-mobile is able to help with this. But unfortunately it looks like this project is abandoned. I am looking for a better alternative as a dependency or maybe a better design pattern to handle this problem.

How to bind the dynamic data in the resource file for localization using Xamarin Forms

I need to make my app to support for multiple languages. So I had created resource files and also binded the strings.
If some strings are coming as dynamic so how do i bind those values in resource files because those values are coming while app is running. Before start I can't hard code those values in resource files.
Thanks for your suggestions.
how do i bind those values in resource files because those values are
coming while app is running.
I don't think you can bind values in resource files dynamically. You have to put strings in your fresh string resource file in advance, while the strings are generated dynamically and we don't know what they are.
If you want to achieve this:
maybe you can find and add a translator in your app and translate the string you generated.(Just my thinking, I haven't tried this way so far)
You could send the string and language type to your server side to get localizable string in different Language. Ask your server side to translate the string for you.

Attach meta data / custom data to slack messages sent through the API

I am developing a series of Slack apps for my workspace, and some of them are meant to interact with the content (messages) delivered by the other apps : extracting content IDs that may be referred to by other messages
A concrete example :
Suppose I have an app A "FindUser" that is capable of giving me the user profile when a slack user types find me#example.com, and it replies in the thread with a formatted view of the user profile
I am developing an app B "EditTags", which basically gives me a right click option with "edit tags" (see Slack's Interactive Components/Actions), the idea being that a user could first ask app A to find a user, and then right click on the reply from App A and click the "edit tags" action given by the other app. What this app B does it actually retrieve the tags for the user mentionned by the previous message from app A, and in another reply to the thread it gives some controls to either delete an existing tag OR it shows a select with autocomplete to add new tags.
The B app needs to retrieve the user ID that the A app mentionned previously. So I need some way to pass that data directly in the slack message. When looking at the examples, slack does not seem to provide a way to add arbitrary "metadata" to a message, am I wrong ? Do you have workaround for this ? I mean I could totally send the user ID say, in the footer, so I can just read the footer, but I was planning to use the footer for something else... Is there a way to pass metadata hrough properties that would be hidden to the end user ?
Although this does not feel relevant, I am building a slack nodeJS app using the node slack sdk (and especially the #slack/interactive-messages package)
For the most part the Slack API does not provide any official means to attach custom data / meta data to messages. But with some simple "hacks" it is still possible. Here is how:
Approach
The basic approach is to use an existing field of the message as container for your data. Obviously you want to pick a field that is not directly linked to Slack functionality.
Some field are not always needed, so you can just use that field as data container. Or if its needed, you can include the functional value of that field along with your custom data in the data container.
For example for message buttons you could use the value field of a button and structure your code in a way that you do not need it in its original function. Usually its sufficient to know which button the user client (via the name field), so the value field is free to be used for your custom data. Or you can include the functional value of your button along with the custom data in a data container (e.g. a JSON string) in that field.
Serialization
All messages are transported through HTTP and mostly encoded as UTF-8 in JSON. So you want to serialize / de-serialize your data accordingly, especially if its binary data. If possible I would recommend to use JSON.
Length
The maximum allowed length of most fields is documented in the official Slack API documentation. e.g. for the value field for message buttons can contain up to 2.000 characters. Keep in mind that you need to consider the length of your data after serialization. e.g. if you convert binary data into Base64 so it can be transported with HTTP you will end up with about 1.33 characters for every byte.
Contents
In general I would recommend to keep your data container as small as possible and not include the actual data, but only IDs. Here are two common approaches:
Include IDs of your data objects and load the actual objects
from a data store when the request is later processed.
Include the ID of server session and when processing the request you
can restore the corresponding server session which contains all data
objects.
In addition you might need to include functional values so that the functionality of the field you are using still works (e.g. value of a menu option, see below)
Implementation
Dialogs
Dialogs provide an official field for custom data called state. Up to 3.000 characters.
Message buttons
For Message buttons you can use the message action fields / value. Up to 2.000 characters. Its also possible to use the name field, but I would advise against it, because the maximum allowed length of that field is not documented.
Message menus
For Message menus you can use the value field of an option or the name field of the menu action.
Usually the value field is the better approach, since you have a documented max length of 2.000 and it gives you more flexibility. However, you will need to combine you custom data with the actual functional value for each option. Also, this will not work for dynamic select elements (like users), where you can not control the value field.
When using the name field note, keep in mind that the maximum allowed length of name is not documented, so you want to keep you data as short as possible. Also, if you want to use more than one menu per attachment you need to include the actual name of the menu into your data container.
Normal message attachments
Normal message attachments do not contain any suitable field to be used as container for custom data, since all fields are linked to Slack functionality.
Technically you could use the fallback field, but only if you are 100% sure that your app is never used on a client that can not display attachments. Otherwise your data will be displayed to the user.

filtering kml in a static map

i'm developing a desktop application, not web.
The software environment is Windows and VB10.
In my user interface I have a browser where I want to show a map, issuing an address like http://maps.google.com/maps?q= and then I indicate a URL where I have put a KML file with my data.
The problem is: is it possible to filter the data in the KML file in order to show only a subset of them ?
Basically you have two options:
Pass parameters to a service which generates your filtered KML on the fly.
Do it in JavaScript in your browser interface.
Based on your question, I am going to assume option one is out. For option two there are tons of examples on the web, but basically you need to parse the KML yourself and write JavaScript code to handle it however it needs to be done to achieve your filtering, you cannot pass the KML URL to google maps directly and achieve any of this behaviour.
Possibly useful example: http://www.gpsvisualizer.com/examples/google_folders.html
UPDATE
Based on conversation in the comments:
The only other thing I can think of is to create your own map page with the JavaScript to do what you want on it (like http://gpsvisualizer.com/examples/google_folders.html linked above) and then embedding it in your app instead of the google map. Essentially encapsulating the features you want. So instead of maps.google.com/maps?q= in your app you have myMapURL.com/MyMap?querystring which is your google maps wrapper with the desired filtering. Otherwise I think you are out of luck based on your current setup.

Resources