1Date::Manip::Lang(3) User Contributed Perl Documentation Date::Manip::Lang(3)
2
3
4
6 Date::Manip::Lang - language support for Date::Manip
7
9 Date::Manip supports a number of different languages when parsing
10 dates, and more can be added.
11
13 Currently, the following languages are supported by Date::Manip. The
14 version of Date::Manip where they were added is included (so you can
15 see the minimum version of Date::Manip needed to parse each).
16
17 The language can be chosen by setting the Language config variable to
18 the name of the language or any of the aliases included in the table.
19
20 All names and aliases are case insensitive.
21
22 Language Version Aliases
23
24 English default en, en_us
25
26 Catalan 5.43 ca
27 Danish 5.41 da
28 Dutch 5.32 Nederlands, nl
29 Finnish 6.31 fi, fi_fi
30 French 5.02 fr, fr_fr
31 German 5.31 de, de_de
32 Italian 5.35 it, it_it
33 Norwegian 6.21 nb, nb_no
34 Polish 5.32 pl, pl_pl
35 Portuguese 5.34 pt, pt_pt
36 Romanian 5.35 ro, ro_ro
37 Russian 5.41 ru, ru_ru
38 Spanish 5.33 es, es_es
39 Swedish 5.05 sv
40 Turkish 5.41 tr, tr_tr
41
43 Adding a language is easily done (if you're fluent in both English and
44 the other language). If you want to add a new language, do the
45 following:
46
47 Language name
48 When you submit the new language, I'll need the name of the
49 language (of course) and any common locale names that might be
50 useful for people to select the language.
51
52 For example, if you were creating a Spanish translation (which is
53 not necessary since it already exists), I would need the following
54 list:
55
56 spanish es es_es
57
58 Copy the english module
59 Copy the english.pm file (which is in lib/Date/Manip/Lang in the
60 Date::Manip distribution) to the new language (i.e. spanish.pm in
61 this example).
62
63 Set some variables in the new module
64 The new module (spanish.pm) will need a few simple modifications.
65 Change the package name from 'english' to 'spanish'.
66
67 Fix the @Encodings lines. Most languages can be written in more
68 than one encoding. The first encoding in the list should be utf-8
69 and the last should be perl. Include any other encodings that
70 should be supported as well.
71
72 Set the $YearAdded and $LangName appropriately.
73
74 Translate the language terms
75 The data section of the module is fairly straightforward to
76 translate.
77
78 Every term is defined in the Date::Manip::Lang::english document
79 (or in any of the other language module documents), so please refer
80 to it to find out what each element means. Then replace the
81 English version with the new translation.
82
83 There are some requirements:
84
85 1) Every element should be defined (except for the sephm and sepms
86 elements which are optional).
87
88 2) The module must be written using UTF-8 characters if the
89 language includes any non-ASCII characters.
90
91 3) Each element includes a list of values (different variations of
92 the element). In most cases, the order of the values for each
93 element is not important since they are just used to create a
94 regular expression for parsing dates, but a few of them are also
95 used to determine printable values using the
96 "Date::Manip::Date::printf" method (or the "UnixDate" function).
97 These elements are:
98
99 Element printf directive
100
101 ampm %p
102 day_abb %a
103 day_char %v
104 day_name %A
105 month_abb %b
106 month_name %B
107 nth %E
108
109 For each of these, the value that should be printed out must be the
110 first value in the list.
111
112 4) When possible, if a language includes characters that are
113 essentially ASCII characters with a punctuation mark, please
114 include a variation of the value which is just ASCII with the
115 punctuation removed. For example, the spanish name for Saturday in
116 ASCII would be written sabado, but in reality, the first 'a' has an
117 accent over it. This word should appear twice... first in full
118 UTF-8 encoding, and second as all ASCII. If the language (Russian
119 for example) has no ASCII equivalent, just include the UTF-8
120 representation.
121
122 Feel free to contact me if you have any questions.
123
125 In the language file, there is one special value named _special_rules.
126 This is a hash of special parsing rules that will be applied for this
127 language.
128
129 Currently the following rules are available:
130
131 remove_trailing_period
132 If this is set, trailing periods will be removed.
133
134 For example, in German, default output of the date command includes
135 a day of month with a trailing period. For example:
136
137 Mo 3. Jan 11:00:00 EST 2022
138
139 If this rule is set, periods followed by whitespace (or an end of
140 string) are stripped.
141
142 remove_parens
143 This will strip parentheses () from a string.
144
145 strip_word
146 This is a list of words that will be stripped from a string. Each
147 word must be bracketed by the start/end of the string or
148 whitespace.
149
151 Date::Manip - main module documentation
152
154 This script is free software; you can redistribute it and/or modify it
155 under the same terms as Perl itself.
156
158 Sullivan Beck (sbeck@cpan.org)
159
160
161
162perl v5.36.0 2023-03-08 Date::Manip::Lang(3)