Debian Codegraph @

lib/Date/Manip/Lang.pod

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