有没有办法在 macOS 的 shell 脚本中 return 当前基于区域的小数点和千位分隔符?

Is there a way to return the current region-based decimal and thousands separators in a shell script on macOS?

我想要一种根据区域设置 return 当前小数点和千位分隔符的方法。我知道您可以使用 locale decimal_pointlocale thousands_sep 获取基于语言的分隔符,如果您设置了自定义分隔符,则可以使用 defaults read -g AppleICUNumberSymbols,但我找不到方法 return 基于区域的值。

例如,在“语言和地区系统偏好设置”页面中,首选语言设置为英语,地区设置为法国。我想要 return 千位分隔符为“ ”,小数点分隔符为“,”。

好的,根据 Larme 对 Foundation.framework 的建议,我提出了以下解决方案,它将在 shell 脚本中使用 osascript 访问 NSNumberFormatter 提供我想要的内容:

osascript -e 'use framework "Foundation"' -e 'return (decimalSeparator of init() of alloc() of NSNumberFormatter of current application as string)'