vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | -- |
||
3 | -- Sea.lang |
||
4 | -- |
||
5 | -- Localization formatting functions for WoW |
||
6 | -- |
||
7 | -- $LastChangedBy: Sinaloit $ |
||
8 | -- $Rev: 2025 $ |
||
9 | -- $Date: 2005-07-02 18:51:34 -0500 (Sat, 02 Jul 2005) $ |
||
10 | --]] |
||
11 | |||
12 | Sea.lang = { |
||
13 | |||
14 | -- |
||
15 | -- makeLocalizedString(...) |
||
16 | -- |
||
17 | -- Generates localized strings, inserting the arguments in the order |
||
18 | -- which matchers the <##>. E.g. localizeString("<2> <1>", "a", "B"); |
||
19 | -- will generate: "B a". |
||
20 | -- |
||
21 | -- Arguments: |
||
22 | -- (string formatString) arg |
||
23 | -- formatString - string with <1> to <arg.n> to be inserted |
||
24 | -- arg - contains the values to insert |
||
25 | -- |
||
26 | makeLocalizedString = function (...) |
||
27 | ret = arg[1]; |
||
28 | for i=2, arg.n, 1 do |
||
29 | ret = string.gsub (ret, "<"..(i-1)..">", arg[i]); |
||
30 | end |
||
31 | return ret; |
||
32 | end; |
||
33 | |||
34 | -- |
||
35 | -- parseLocalizedString (localizedString, formatString, order, n to parse ) |
||
36 | -- |
||
37 | -- This function reads values back from a localized string. |
||
38 | -- In order to get the values back, you must pass |
||
39 | -- this function the final string, the original format string, |
||
40 | -- the order of the parameters in that string and the n number |
||
41 | -- to parse of out the localized string. |
||
42 | -- |
||
43 | parseLocalizedString = function (str, fmt, ord, n) |
||
44 | local ret = {}; |
||
45 | fmt1 = string.gsub (fmt, "%b<>", "(.+)"); |
||
46 | for i=1, n, 1 do |
||
47 | ret[ord[i]] = string.gsub(str, fmt1, "%"..i); |
||
48 | end |
||
49 | return unpack(ret); |
||
50 | end; |
||
51 | }; |