• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Preferences and l10n
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Preferences and l10n


  • Subject: Re: Preferences and l10n
  • From: Shane Stanley <email@hidden>
  • Date: Mon, 18 May 2015 10:16:04 +1000

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.

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Preferences and l10n
      • From: Jean-Christophe Helary <email@hidden>
References: 
 >Preferences and l10n (From: Jean-Christophe Helary <email@hidden>)

  • Prev by Date: Why isn't the Apply Images command in PhotoShop accessible to AppleScript?
  • Next by Date: Re: Why isn't the Apply Images command in PhotoShop accessible to AppleScript?
  • Previous by thread: Re: Preferences and l10n
  • Next by thread: Re: Preferences and l10n
  • Index(es):
    • Date
    • Thread