0

I want to create localized NSAlert for right to left language like Arabic and Hebrew.

How can I reverse the layout so that Icon is on the right, TextField on the left, and also buttons start from the left side of the alert?

I can't seem to find the proper answer anywhere.

Thanks, N

Nenad
  • 335
  • 1
  • 7
  • when you try it today, what do you get? can you edit your question to show a screenshot? MacOS runs under *many* languages, including Arabic & Hebrew, so I'm certain that the text appears Right to Left correctly. I don't think the buttons or icons necessarily would need to be reversed, though. – Michael Dautermann Nov 06 '14 at 15:07
  • Text is aligned properly, but the elements are not reversed. My question is how do i do it programatically? – Nenad Nov 06 '14 at 15:13

1 Answers1

1

Apple has a Human Interface Guidelines that are somewhat strict about the ordering & placement of things. For example, in the "Place buttons appropriately" section of this HIG documentation, buttons most likely to be touched usually go on the right.

If NSAlert behavior doesn't look right to you, the easiest way to rearrange things is to implement your own NSView customized to look like a NSAlert. But if Apple hasn't changed the order of things for Right-to-Left languages, then it's a pretty safe bet that most of your Arabic & Hebrew customers are going to be expecting their buttons to be placed in the same place where all other apps are going to have their buttons placed. That is, the button that's most likely to be touched should still be in the bottom right.

Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
  • Thanks, I've never worked with this before and I'm not experienced with OS X API so this is a shot in the dark. But my idea was to get subviews from `[[alert window] contentView]` remove them and add them in some ortder/layout. But i don't exacly know how to do this. I guess this is easier then making my own `NSView` with the exact same parameters as the one in `NSAlert`. Also, when I iterate through subviews `for (NSView *view in [[[alert window] contentView] subviews]) { NSLog(@"%d Is of type %@", i++, [view className]); }` shows 7 buttons (i added 3) and 1 textfield i added. – Nenad Nov 06 '14 at 21:32
  • And also, when i switch to Arabic, for example, all the OS X dialogs are reversed (buttons start from the left side, image is on the right and text fields on the left). I guess there should be some alternate layout for the dialogs, alerts and everything to use, but I can't seem to dig it up. – Nenad Nov 06 '14 at 21:36
  • are the application dialogs that are reversed (because [application developers like you and I have control over how localization can be done](https://developer.apple.com/internationalization/), or are these MacOS (i.e. Apple controlled, MacOS owned) dialogs that are correctly reversed? There's a difference... – Michael Dautermann Nov 06 '14 at 22:56
  • Yes of course, all are OS owned dialogs. I see other applications having the reversed dialogs too and i guess they have made their own view and inserted it into `NSAlert`and other dialogs, but I can't believe that Apple wouldn't provide some API to reverse this easily when they flip all of their dialogs for Ara and Heb in the first place! Thanks for your answers, I guess there's no other way of doing it but making my own NSView and insert it instead of theirs. – Nenad Nov 07 '14 at 09:28