Adobe 65007312 Programming Guide - Page 147

The LOC function

Page 147 highlights

CHAPTER 7: Using ZStrings for Localization The LOC function 147 Sequence ^d ^L ^V ^# ^` ^^ ^0 - ^9 ^U+xxxx Replacement Greek capital delta backslash ("\") vertical bar ("|") command key (in Mac OS) accent grave ("`") circumflex ("^") Marks insertion point for additional LOC argument strings; see "The LOC function" on page 147. Unicode code point U+xxxx The LOC function The global LOC function takes a ZString argument, and automatically performs the table lookup to resolve the display string for the current locale. If it cannot find a matching string in a dictionary for the current locale, or if there is no dictionary for the current locale, it returns the default string provided with the ZString. You can use the LOC function anywhere you specify display strings: X In the title for your Export Service Provider X In the title for menu items that you add X In the title and value properties of UI elements Any of these properties can take a simple string or a LOC and ZString value. You are not required to use the LOC function if you do not need to localize the text of your plug-in. Here is an example of localizing the text that identifies an Export Service Provider in the Export destination section of the Export dialog: LrExportServiceProvider = { title = LOC "$$$/MyPlugin/Name=My Plug-in", file = 'MyPluginExportServiceProvider.lua', ... }, The LOC function also allows you to combine strings using placeholders in the ZString's value string, and additional string arguments to the function. The placeholders use "hat" notation with a numeric value; the first is ^1, the second ^2, and so on. You can specify up to 9 additional string arguments, which are inserted at the placeholder locations ^1 through ^9 in the localized text. For example: LOC( "$$$/Message=Could not open the file ^1 because ^2.", "myfile.jpg", "a disk error occurred" ) The placeholders are replaced by the string arguments, resulting in this string: "Could not open the file myfile.jpg because a disk error occurred."

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204

C
HAPTER
7: Using ZStrings for Localization
The LOC function
147
The LOC function
The global
LOC
function takes a ZString argument, and automatically performs the table lookup to resolve
the display string for the current locale. If it cannot find a matching string in a dictionary for the current
locale, or if there is no dictionary for the current locale, it returns the default string provided with the
ZString.
You can use the
LOC
function anywhere you specify display strings:
X
In the
title
for your Export Service Provider
X
In the
title
for menu items that you add
X
In the
title
and
value
properties of UI elements
Any of these properties can take a simple string or a
LOC
and ZString value. You are not required to use the
LOC
function if you do not need to localize the text of your plug-in.
Here is an example of localizing the text that identifies an Export Service Provider in the Export destination
section of the Export dialog:
LrExportServiceProvider = {
title =
LOC "$$$/MyPlugin/Name=My Plug-in"
,
file = 'MyPluginExportServiceProvider.lua',
...
},
The
LOC
function also allows you to combine strings using placeholders in the ZString’s value string, and
additional string arguments to the function. The placeholders use “hat” notation with a numeric value; the
first is ^1, the second ^2, and so on. You can specify up to 9 additional string arguments, which are
inserted at the placeholder locations ^1 through ^9 in the localized text.
For example:
LOC( "$$$/Message=Could not open the file ^1 because ^2.",
"myfile.jpg", "a disk error occurred" )
The placeholders are replaced by the string arguments, resulting in this string:
"Could not open the file myfile.jpg because a disk error occurred."
^d
Greek capital delta
^L
backslash ("\")
^V
vertical bar ("|")
^#
command key (in Mac OS)
^`
accent grave ("`")
^^
circumflex ("^")
^0 - ^9
Marks insertion point for additional
LOC
argument strings; see
The LOC
function
” on page 147
.
^U+
xxxx
Unicode code point U+
xxxx
Sequence
Replacement