On 17 May 2015, at 11:08 pm, Jean-Christophe Helary <email@hidden> wrote:
1) extract all "local" information (like paths etc) and put them in a preference file
Traditionally AppleScript scripts have just properties, and it hasn't really caught up with the fact that that's no longer acceptable in many situations. There is no built-in method for saving a preference file, so it's essentially a matter of rolling your own, using read/write commands or something like NSUserDefaults. I have an ASObjC script library that does it using user defaults, if you or anyone is interested.
2) create localized versions
You have to create the .lproj folders and .strings files yourself manually. Standard Additions gives you access via the 'localized string' command.
For common things like date- and time-related names, it's simpler to use ASObjC, provided your target is 10.9 or later. For example:
use framework "Foundation" set df to current application's NSDateFormatter's alloc()'s init() df's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"fr_FR") -- only needed if you want other than user's locale set dayNames to df's standaloneWeekdaySymbols() as list set monthNames to df's standaloneMonthSymbols() as list
0000.001 [7] set df to current application's NSDateFormatter's alloc()'s init() --> (NSDateFormatter) <NSDateFormatter: 0x7f8f7ddd8400> 0000.003 [9] set dayNames to df's standaloneWeekdaySymbols() as list --> {"Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"} 0000.004 [10] set monthNames to df's standaloneMonthSymbols() as list --> {"janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}
You need to put it in a script library under 10.9.
But if you're doing much with dates, you might well find it less frustrating to work in NSDates more generally. |