is there a way to set the text of a Label (Toybox.WatchUi.Text) with a localized string programmatically at runtime? I know how to set a localized string for a label from within the user interface XML files and was wondering if this is also possible from within a Monkey C file, e.g. label.setText("#Strings.localization_key")?
I discovered the Github Account of Garmin where they also provide some example code of Applications and I found the solution in one of the projects.
It's simply Rez.Strings.<string_id> with the ID and the respective translation in one of the string resource files.
However, it does not seem to work to concatenate the localized String with another string and put the concatenation as text in the label. Obviously, the internal String-ID is then displayed rather than the actual string. This behavior occurred for me with the Connect IQ SDK 1.2.5.
Related
I have an app that is used to track/manage livestock. It currently supports one species, Sheep. We want to begin supporting multiple different species, like Goats, and Cattle. My first thought was to create something similar to NSLocalizedString(text, comment) like SpeciesString(text, species, comment) which would take the English string and the species name and translate the Sheep term Ram to the Cattle term Bull. And internal to that, I could use NSLocalizedString() to then further translate that to the proper language so that in the future I could support multiple languages as well.
I see that I can pass a tableName to NSLocalizedString() so that it will use a different file other than Localizeable.strings and that would allow me to programmatically pull values from a Spanish language file that is focused on Cattle instead of Sheep (something like Localizeable-sheep.strings and Localizeable-cattle.strings), but that won't help me with all of the text that is in the storyboard.
I know that there is built-in support for localization with the storyboard, but the problem I'm having is that when the text comes to my code, for example in viewDidLoad, it will already have been translated to the other language, for example Spanish. I would prefer to find a way to make the text in my views already have the right Language+Species combination by the time it gets to my code. But even if I did rely on programmatically swapping out the strings to use the right Species, the English will already been changed to Spanish and I'll get Carnero instead of Ram and if I try to pass that through to my SpeciesString() it won't match my underlying data, because my underlying data is keying off of the English version of the text.
Is there a way to create a custom language? I've seen this code that is used to change the localization language on the fly, and it works for swapping between en and es, but I can't create my own fake languages like en-sheep and es-sheep.
Is there either:
a) a way to create my own custom language so that the localization system will just pick my correct Language+Species combination?
or
b) a way to tell the Storyboard which table name/filename to pull strings from? So that instead of just having a strings file for my Main.storyboard be called es.lproj/Main.strings but I could instead have
es.lproj/Main-sheep.strings and es.lproj/Main-cattle.strings?
I think my inability to get my "custom language" to work was just an accidental oversight. I created an es-sheep.lproj/Main.strings and used the other SO post to programmatically set my language to es-sheep and it didn't seem to work...
... but it turned out that I had created those directories and files, but forgotten to add them to the project. Once I manually added them to the project, it started working and I was able to use my custom localizations.
I am currently working on an iOS app and localizing it into multiple languages but have faced an annoying (not breaking) issue.
When i would add a new localization for my storyboard xcode will automatically populate the strings, which is very nice. The issue i am having is that i have multiple interfaces which both have a back button. The text on these is of course the same and their translations are as well.
The question i was wondering about, is it possible, without using strings.localizable, to somehow merge multiple object translations into one?
This is how it would currently look:
"Pnu-Ec-HAj.normalTitle" = "Back";
"Rtx-fT-rdc.normalTitle" = "Back";
But it would be way easier if there was a syntax such as
"Pnu-Ec-HAj.normalTitle", "Rtx-fT-rdc.normalTitle" = "Back";
(this syntax is not correct obviously)
I have looked around quite a while but have not found any answers to this question yet.
Thanks for reading.
I'd recommend referencing every text in your storyboard in code, and setting the text on viewDidLoad like, e.g.:
buyButton.titleLabel.text = NSLocalizedString(#"SHOP_BUY_BUTTON_TEXT",#"Button for buying product in detail view");
It's loads of work if you have huge storyboards, but in the end you have a clean Localizable.strings with concise keys and comments, providing necessary context for your translators.
I prefix the key with the section of the app, so for example SHOP_***, USER_SETTINGS_***, etc.
In addition, we use a service like OneSky to organize our translations online and update them from the cloud (not affiliated with them, and it's not without its teething problems either).
Unfortunately the .strings files are key-value files and, by nature, there must be a key (that is composed by the nib ID of the element followed by the property) and the associated string value.
As Apple describes in the precedent link:
The standard strings file format consists of one or more key-value pairs along with optional comments. The key and value in a given pair are strings of text enclosed in double quotation marks and separated by an equal sign.
then, your idea is not supported by the .strings files.
The only way to support that feature is by using the NSLocalizedString in code.
I am having a drupal 7 node about software releases. The title field of the release is
"Release v6-05-01"
I need to construct a URL based on this title that goes like this http://example.com/html605/Class.html
I know hot to construct the URL but the "605" bit is tricky because I have no token for it.
I thought that maybe I could take the characters from the title one by one? Is this possible in Drupal 7?
One solution could be to add a new field (eg "version number", text field) to your content type to hold the "605" string, and then use this token (typically : [node:field_version_number]) to construct your URL. But you'll have one more field to manage when creating new nodes, and maybe a lot of work to process existing nodes.
Depending on how this number is constructed from the node title, you could try using Computed Field or Dynamic Field, and create a PHP computed field. In PHP you could build the version number with some substr logic based on the node title (its value is available in the PHP snippet). This way you don't have to fill the new field for each new node and existing nodes should be automatically updated.
Good luck
i need to localize a Reporting Services-report (.rdlc) and i would like to do it using a ressource-file (.resx).
I found pages like this and that and they use custom code to achieve their target.
But pages like Setting the Report Language Parameter in a URL give me the impression that localization in reports is possible without custom code.
So, it is possible to localize a Reporting Services-report without custom code ?
If so, is there a tutorial that explains how it's done?
What in the report do you want to localize?
values from the database? Those should be retrieved from the database in the appropriate language already
fixed labels and textboxes on the report? I have not yet seen any compelling way to doing this - you can either have
one report "skeleton" / template per language (and pick the one you need)
if the number of elements is manageable, define report parameters which you can set from the calling code, to set the labels and texts
use some custom .NET extension for handling localization
It's not really an awfully pretty picture, indeed - I'd be most interested in better solutions myself! (I typically need to support 3-4 languages for any report - and I'm using only server-based .RDL files, no .RDLC, so any localization that depends on client-side resource files is not usable in my case)
I would add one method when it comes to labels and textboxes:
Create a placeholder element within the textbox and use Expression field to
use a Switch clause , switching on the Language parameter.
It's not superpretty, but also works pretty well for 3-4 languages
I am passing parameters to the report for labels etc, and after adding the parameters to the report (using the menu option Report -> Parameters in VS2008) you can then use the values of these parameters to localise the labels. This is workiiing well enough, although it would be nicer to be abkle to refer to resource keys immediately from your form labels etc.
I need to parse large text (about 1000 pages of word or pdf document)and place some of the text inside this document into database fields
I found that the only thing I can distinguish the text I want to extract is the format , it is always "Helvetica-Condensed" size 12
can I do that ? I know how to use the string functions but what I should use to test the format ?
as I said the text is stored inside word document or PDF
if there is third party component can do no problem please refer it to me
Thanks
There is QuickPDF. The price is $249,00.
The other option is to code it yourself. The file specification is available online, and if your only trying to rip the text out of the document this should guide you most of the way.
The only thing to be careful of are documents which are built entirely from images. In that scenario (no matter what you use to read the file) you will also need an OCR type of application. To see if this is the case or not, open a sample of the type of file you are wanting to "extract" text from, select the text to copy then try to paste into notepad.