I'm developing iPad international application.
I'm using methods NSLocalizableString to translate my application.
I have added keyword manually in my Localizable.strings in English and in French named "Orders" with value.
When I call my method NSLocalizableString with the keyword, it didn't found my keyword and don't apply the translation.
For keyword above and below, it's working perfectly.
Some code parts :
**Localizable.strings**
/* Change datas */
"ChangeDatas" = "Modifier les données";
/* Orders */
"Orders" = "Détails de votre commande";
/* Label */
"SomeLabel" = "Label";
**file.m**
//Work fine
NSLog(#"My data translation : %#", NSLocalizedString(#"ChangeDatas", #"Change datas"));
//Don't work
NSLog(#"My orders translation : %#", NSLocalizedString(#"Orders", #"Orders"));
Are you sure your editor was working in the right encoding? Also, with the correct line endings?
It can't hurt to check your .strings file with the plutil command.
Are you sure you've edited the .strings file for the same language/locale that you're using at runtime?
Related
I'm creating some apache velocity templates and formatting the code(intellij Idea) breaks the template, because the text parts of the template are automatically indented.
When there's only a single line of the output text, then the indent is not preserved in the output:
#macro(body)
#if(${someCondition})
Hello
#end
#end
The output is:
Hello
The problem with multiline text output is this:
#macro(body)
#if(${someCondition})
Hello
World
#end
#end
And the output:
Hello
World
Is there some way to strip the indent of the text part based on the sorrounding code? I'd like to avoid ugly formatted templates like this:
#macro(body)
#if(${someCondition})
Hello
World
#end
#end
The code which uses the template:
final VelocityEngine engine = new VelocityEngine();
engine.init();
final VelocityContext context = new VelocityContext();
//put variables into context
engine.evaluate(context, outputWriter, "LOG", inputString);
Maybe there's something I can put into VelolocityContext, but I wasn't able to find it.
I have been writing a test with "Subliminal's" "SLTextField" and have run into some really annoying issues lately.
I have written a test which should update a text field, clear it, and update it again.
For some reason when I use "SLTextField" to change the element text I consistently receive errors stating that "SLTextFields" aren't tappable elements. Is this true? If so, what is the point of having an "SLTextField" class at all?
I can rewrite the same test code to find the element as an "SLElement", at which point I can tap the element, open up a keyboard object and type the necessary text, but it seems like I'm circumventing the entire functionality of Subliminal in doing this.
What's wrong w/"SLTextField"?
Code:
SLTextField *textField = [SLTextField elementWithAccessibilityLabel:fieldName];
SLWaitUntilTrue([textField isTappable], DEFAULT_TIMEOUT);
textField.text = newValue;
The above code throws an error, stating that "textField" never becomes tappable. Alternatively, the code below works perfectly, though it's unnecessarily verbose and seems to make "SLTextField" superfluous.
Code:
SLElement *field = [SLElement elementWithAccessibilityLabel:fieldName];
[field tapAtActivationPoint];
//fill with text
SLKeyboard *kb = [SLKeyboard keyboard];
SLKeyboardKey *deleteKey = [SLKeyboardKey elementWithAccessibilityLabel:#"Delete"];
while(![field.value isEqualToString:#""]){
[deleteKey touchAndHoldWithDuration:1.2];
}
[kb typeString:newValue];
SLKeyboardKey *doneKey = [SLKeyboardKey elementWithAccessibilityLabel:#"Next"];
if(![doneKey isValid]){
doneKey = [SLKeyboardKey elementWithAccessibilityLabel:#"Done"];
}
[doneKey tap];
[kb hide];
Is your TextField within a TableViewCell? And are you seeing this on iOS 7?
If so, it might have been fixed by https://github.com/inkling/Subliminal/pull/202 (merged 6/6/2014).
I created 2 InfoPlist.strings, one in portuguese and the other in english.
i use my string in .strings file like this:
"BtnTitle" = "Title"; (English)
"BtnTitle" = "Título"; (Portuguese)
when i debug either in the simulator and in the device gives me only :
BtnTitle as the result of the NSLog :
NSLog(#"Titulo : %#", NSLocalizedString(#"BtnTitle", #""));
The Log dont give me the property of the object "Title" or "Título", but the object name "BtnTitle"
InfoPlist.strings is localization for Info.plist. UI strings should go in Localizable.strings.
I tried adding a Localizable.strings file and add some strings to test with, everything works fine.
However, when I try to add a localization things starts to get weird. I am able to add a localization (english and russian) and I can see in finder that the files are listed in the two folders; ru.lproj and en.lproj.
When I clean and build I get the following compilation error:
Copy .strings file Error
The file "Localizable.strings" couldn't be opened because there is no such file.
Fixed it by a push in the right direction from this link provided by tiguero in the comment.
I looked further into the .pbxproj file and found this funky row, that looked fishy:
6AAE55EC1551A42500C1F3F0 /* Localizable.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = "<group>"; };
I removed it, cleaned and rebuild. It is now replaced by the following line:
6AC473DC1624BF3E00503305 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6AC473DE1624BF3E00503305 /* Localizable.strings */; };
And it works!
I have RTF text which I am showing to the user on Mac. Now I need to replace some text. The text has some images inline. When I execute the following code, the images are getting lost. I am using c#, Mono and Monobjc to run this on mac.
NSText _questionView;
// some initialisation code which I have skipped
//
NSRange range = NSRange.NSMakeRange(0, _questionView.TextStorage.Length);
NSData oldString = _questionView.RTFFromRange(range);
if (oldString != null)
{
string s = oldString.ConvertRTFToString();
_questionView.ReplaceCharactersInRangeWithRTF(range, s.ConvertToNSData());
_questionView.SelectedRange = NSRange.NSMakeRange(0,0);
// After this line the inline images are lost.
}
You are losing the images because you are converting the RTF content to NSString. NSString can only carry text, not attributes. You should consider using NSAttributedString instead for the text manipulation, in order to keep the RTF attributes (style, images, etc.).