Skip to main content

deep_time/locale/
mod.rs

1pub mod en;
2use en::*;
3
4#[cfg(feature = "parse")]
5pub mod lang_data;
6#[cfg(feature = "parse")]
7pub mod lang_map;
8
9#[cfg(feature = "multi-lang")]
10pub mod multi_lang;
11#[cfg(feature = "multi-lang")]
12use multi_lang::*;
13
14pub(crate) struct FormatNames {
15    pub weekdays_full: &'static [&'static [u8]; 7],
16    pub weekdays_abbr: &'static [&'static [u8]; 7],
17    pub months_full: &'static [&'static [u8]; 12],
18    pub months_abbr: &'static [&'static [u8]; 12],
19}
20
21impl Lang {
22    #[inline]
23    pub(crate) const fn names(self) -> &'static FormatNames {
24        match self {
25            Lang::En => &EN_NAMES,
26            #[cfg(feature = "fr")]
27            Lang::Fr => &FR_NAMES,
28            #[cfg(feature = "de")]
29            Lang::De => &DE_NAMES,
30            #[cfg(feature = "es")]
31            Lang::Es => &ES_NAMES,
32        }
33    }
34}
35
36/// Language codes following ISO 639-1 standard (two-letter codes).
37/// Default is En (English)
38#[allow(dead_code)]
39#[non_exhaustive]
40#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
41#[cfg_attr(feature = "tsify", derive(tsify::Tsify))]
42#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
43pub enum Lang {
44    /// English (default) — always available
45    #[default]
46    En,
47
48    // /// Afar
49    // #[cfg(feature = "aa")]
50    // Aa,
51    // /// Abkhazian
52    // #[cfg(feature = "ab")]
53    // Ab,
54    // /// Avestan
55    // #[cfg(feature = "ae")]
56    // Ae,
57    // /// Afrikaans
58    // #[cfg(feature = "af")]
59    // Af,
60    // /// Akan
61    // #[cfg(feature = "ak")]
62    // Ak,
63    // /// Amharic
64    // #[cfg(feature = "am")]
65    // Am,
66    // /// Aragonese
67    // #[cfg(feature = "an")]
68    // An,
69    // /// Arabic
70    // #[cfg(feature = "ar")]
71    // Ar,
72    // /// Assamese
73    // #[cfg(feature = "as")]
74    // As,
75    // /// Avaric
76    // #[cfg(feature = "av")]
77    // Av,
78    // /// Aymara
79    // #[cfg(feature = "ay")]
80    // Ay,
81    // /// Azerbaijani
82    // #[cfg(feature = "az")]
83    // Az,
84    // /// Bashkir
85    // #[cfg(feature = "ba")]
86    // Ba,
87    // /// Belarusian
88    // #[cfg(feature = "be")]
89    // Be,
90    // /// Bulgarian
91    // #[cfg(feature = "bg")]
92    // Bg,
93    // /// Bihari languages
94    // #[cfg(feature = "bh")]
95    // Bh,
96    // /// Bislama
97    // #[cfg(feature = "bi")]
98    // Bi,
99    // /// Bambara
100    // #[cfg(feature = "bm")]
101    // Bm,
102    // /// Bengali
103    // #[cfg(feature = "bn")]
104    // Bn,
105    // /// Tibetan
106    // #[cfg(feature = "bo")]
107    // Bo,
108    // /// Breton
109    // #[cfg(feature = "br")]
110    // Br,
111    // /// Bosnian
112    // #[cfg(feature = "bs")]
113    // Bs,
114    // /// Catalan
115    // #[cfg(feature = "ca")]
116    // Ca,
117    // /// Chechen
118    // #[cfg(feature = "ce")]
119    // Ce,
120    // /// Chamorro
121    // #[cfg(feature = "ch")]
122    // Ch,
123    // /// Corsican
124    // #[cfg(feature = "co")]
125    // Co,
126    // /// Cree
127    // #[cfg(feature = "cr")]
128    // Cr,
129    // /// Czech
130    // #[cfg(feature = "cs")]
131    // Cs,
132    // /// Church Slavic
133    // #[cfg(feature = "cu")]
134    // Cu,
135    // /// Chuvash
136    // #[cfg(feature = "cv")]
137    // Cv,
138    // /// Welsh
139    // #[cfg(feature = "cy")]
140    // Cy,
141    // /// Danish
142    // #[cfg(feature = "da")]
143    // Da,
144    /// German
145    #[cfg(feature = "de")]
146    De,
147    // /// Divehi
148    // #[cfg(feature = "dv")]
149    // Dv,
150    // /// Dzongkha
151    // #[cfg(feature = "dz")]
152    // Dz,
153    // /// Ewe
154    // #[cfg(feature = "ee")]
155    // Ee,
156    // /// Greek
157    // #[cfg(feature = "el")]
158    // El,
159    // /// Esperanto
160    // #[cfg(feature = "eo")]
161    // Eo,
162    /// Spanish
163    #[cfg(feature = "es")]
164    Es,
165    // /// Estonian
166    // #[cfg(feature = "et")]
167    // Et,
168    // /// Basque
169    // #[cfg(feature = "eu")]
170    // Eu,
171    // /// Persian
172    // #[cfg(feature = "fa")]
173    // Fa,
174    // /// Fulah
175    // #[cfg(feature = "ff")]
176    // Ff,
177    // /// Finnish
178    // #[cfg(feature = "fi")]
179    // Fi,
180    // /// Fijian
181    // #[cfg(feature = "fj")]
182    // Fj,
183    // /// Faroese
184    // #[cfg(feature = "fo")]
185    // Fo,
186    /// French
187    #[cfg(feature = "fr")]
188    Fr,
189    // /// Western Frisian
190    // #[cfg(feature = "fy")]
191    // Fy,
192    // /// Irish
193    // #[cfg(feature = "ga")]
194    // Ga,
195    // /// Scottish Gaelic
196    // #[cfg(feature = "gd")]
197    // Gd,
198    // /// Galician
199    // #[cfg(feature = "gl")]
200    // Gl,
201    // /// Guarani
202    // #[cfg(feature = "gn")]
203    // Gn,
204    // /// Gujarati
205    // #[cfg(feature = "gu")]
206    // Gu,
207    // /// Manx
208    // #[cfg(feature = "gv")]
209    // Gv,
210    // /// Hausa
211    // #[cfg(feature = "ha")]
212    // Ha,
213    // /// Hebrew
214    // #[cfg(feature = "he")]
215    // He,
216    // /// Hindi
217    // #[cfg(feature = "hi")]
218    // Hi,
219    // /// Hiri Motu
220    // #[cfg(feature = "ho")]
221    // Ho,
222    // /// Croatian
223    // #[cfg(feature = "hr")]
224    // Hr,
225    // /// Haitian Creole
226    // #[cfg(feature = "ht")]
227    // Ht,
228    // /// Hungarian
229    // #[cfg(feature = "hu")]
230    // Hu,
231    // /// Armenian
232    // #[cfg(feature = "hy")]
233    // Hy,
234    // /// Herero
235    // #[cfg(feature = "hz")]
236    // Hz,
237    // /// Interlingua
238    // #[cfg(feature = "ia")]
239    // Ia,
240    // /// Indonesian
241    // #[cfg(feature = "id")]
242    // Id,
243    // /// Interlingue
244    // #[cfg(feature = "ie")]
245    // Ie,
246    // /// Igbo
247    // #[cfg(feature = "ig")]
248    // Ig,
249    // /// Sichuan Yi
250    // #[cfg(feature = "ii")]
251    // Ii,
252    // /// Inupiaq
253    // #[cfg(feature = "ik")]
254    // Ik,
255    // /// Ido
256    // #[cfg(feature = "io")]
257    // Io,
258    // /// Icelandic
259    // #[cfg(feature = "is")]
260    // Is,
261    // /// Italian
262    // #[cfg(feature = "it")]
263    // It,
264    // /// Inuktitut
265    // #[cfg(feature = "iu")]
266    // Iu,
267    // /// Japanese
268    // #[cfg(feature = "ja")]
269    // Ja,
270    // /// Javanese
271    // #[cfg(feature = "jv")]
272    // Jv,
273    // /// Georgian
274    // #[cfg(feature = "ka")]
275    // Ka,
276    // /// Kongo
277    // #[cfg(feature = "kg")]
278    // Kg,
279    // /// Kikuyu
280    // #[cfg(feature = "ki")]
281    // Ki,
282    // /// Kuanyama
283    // #[cfg(feature = "kj")]
284    // Kj,
285    // /// Kazakh
286    // #[cfg(feature = "kk")]
287    // Kk,
288    // /// Greenlandic
289    // #[cfg(feature = "kl")]
290    // Kl,
291    // /// Khmer
292    // #[cfg(feature = "km")]
293    // Km,
294    // /// Kannada
295    // #[cfg(feature = "kn")]
296    // Kn,
297    // /// Korean
298    // #[cfg(feature = "ko")]
299    // Ko,
300    // /// Kanuri
301    // #[cfg(feature = "kr")]
302    // Kr,
303    // /// Kashmiri
304    // #[cfg(feature = "ks")]
305    // Ks,
306    // /// Kurdish
307    // #[cfg(feature = "ku")]
308    // Ku,
309    // /// Komi
310    // #[cfg(feature = "kv")]
311    // Kv,
312    // /// Cornish
313    // #[cfg(feature = "kw")]
314    // Kw,
315    // /// Kyrgyz
316    // #[cfg(feature = "ky")]
317    // Ky,
318    // /// Latin
319    // #[cfg(feature = "la")]
320    // La,
321    // /// Luxembourgish
322    // #[cfg(feature = "lb")]
323    // Lb,
324    // /// Ganda
325    // #[cfg(feature = "lg")]
326    // Lg,
327    // /// Limburgish
328    // #[cfg(feature = "li")]
329    // Li,
330    // /// Lingala
331    // #[cfg(feature = "ln")]
332    // Ln,
333    // /// Lao
334    // #[cfg(feature = "lo")]
335    // Lo,
336    // /// Lithuanian
337    // #[cfg(feature = "lt")]
338    // Lt,
339    // /// Luba-Katanga
340    // #[cfg(feature = "lu")]
341    // Lu,
342    // /// Latvian
343    // #[cfg(feature = "lv")]
344    // Lv,
345    // /// Malagasy
346    // #[cfg(feature = "mg")]
347    // Mg,
348    // /// Marshallese
349    // #[cfg(feature = "mh")]
350    // Mh,
351    // /// Maori
352    // #[cfg(feature = "mi")]
353    // Mi,
354    // /// Macedonian
355    // #[cfg(feature = "mk")]
356    // Mk,
357    // /// Malayalam
358    // #[cfg(feature = "ml")]
359    // Ml,
360    // /// Mongolian
361    // #[cfg(feature = "mn")]
362    // Mn,
363    // /// Marathi
364    // #[cfg(feature = "mr")]
365    // Mr,
366    // /// Malay
367    // #[cfg(feature = "ms")]
368    // Ms,
369    // /// Maltese
370    // #[cfg(feature = "mt")]
371    // Mt,
372    // /// Burmese
373    // #[cfg(feature = "my")]
374    // My,
375    // /// Nauru
376    // #[cfg(feature = "na")]
377    // Na,
378    // /// Norwegian Bokmål
379    // #[cfg(feature = "nb")]
380    // Nb,
381    // /// North Ndebele
382    // #[cfg(feature = "nd")]
383    // Nd,
384    // /// Nepali
385    // #[cfg(feature = "ne")]
386    // Ne,
387    // /// Ndonga
388    // #[cfg(feature = "ng")]
389    // Ng,
390    // /// Dutch
391    // #[cfg(feature = "nl")]
392    // Nl,
393    // /// Norwegian Nynorsk
394    // #[cfg(feature = "nn")]
395    // Nn,
396    // /// Norwegian
397    // #[cfg(feature = "no")]
398    // No,
399    // /// South Ndebele
400    // #[cfg(feature = "nr")]
401    // Nr,
402    // /// Navajo
403    // #[cfg(feature = "nv")]
404    // Nv,
405    // /// Chichewa
406    // #[cfg(feature = "ny")]
407    // Ny,
408    // /// Occitan
409    // #[cfg(feature = "oc")]
410    // Oc,
411    // /// Ojibwa
412    // #[cfg(feature = "oj")]
413    // Oj,
414    // /// Oromo
415    // #[cfg(feature = "om")]
416    // Om,
417    // /// Oriya
418    // #[cfg(feature = "or")]
419    // Or,
420    // /// Ossetian
421    // #[cfg(feature = "os")]
422    // Os,
423    // /// Punjabi
424    // #[cfg(feature = "pa")]
425    // Pa,
426    // /// Pali
427    // #[cfg(feature = "pi")]
428    // Pi,
429    // /// Polish
430    // #[cfg(feature = "pl")]
431    // Pl,
432    // /// Pashto
433    // #[cfg(feature = "ps")]
434    // Ps,
435    // /// Portuguese
436    // #[cfg(feature = "pt")]
437    // Pt,
438    // /// Quechua
439    // #[cfg(feature = "qu")]
440    // Qu,
441    // /// Romansh
442    // #[cfg(feature = "rm")]
443    // Rm,
444    // /// Rundi
445    // #[cfg(feature = "rn")]
446    // Rn,
447    // /// Romanian
448    // #[cfg(feature = "ro")]
449    // Ro,
450    // /// Russian
451    // #[cfg(feature = "ru")]
452    // Ru,
453    // /// Kinyarwanda
454    // #[cfg(feature = "rw")]
455    // Rw,
456    // /// Sanskrit
457    // #[cfg(feature = "sa")]
458    // Sa,
459    // /// Sardinian
460    // #[cfg(feature = "sc")]
461    // Sc,
462    // /// Sindhi
463    // #[cfg(feature = "sd")]
464    // Sd,
465    // /// Northern Sami
466    // #[cfg(feature = "se")]
467    // Se,
468    // /// Sango
469    // #[cfg(feature = "sg")]
470    // Sg,
471    // /// Sinhala
472    // #[cfg(feature = "si")]
473    // Si,
474    // /// Slovak
475    // #[cfg(feature = "sk")]
476    // Sk,
477    // /// Slovenian
478    // #[cfg(feature = "sl")]
479    // Sl,
480    // /// Samoan
481    // #[cfg(feature = "sm")]
482    // Sm,
483    // /// Shona
484    // #[cfg(feature = "sn")]
485    // Sn,
486    // /// Somali
487    // #[cfg(feature = "so")]
488    // So,
489    // /// Albanian
490    // #[cfg(feature = "sq")]
491    // Sq,
492    // /// Serbian
493    // #[cfg(feature = "sr")]
494    // Sr,
495    // /// Swati
496    // #[cfg(feature = "ss")]
497    // Ss,
498    // /// Southern Sotho
499    // #[cfg(feature = "st")]
500    // St,
501    // /// Sundanese
502    // #[cfg(feature = "su")]
503    // Su,
504    // /// Swedish
505    // #[cfg(feature = "sv")]
506    // Sv,
507    // /// Swahili
508    // #[cfg(feature = "sw")]
509    // Sw,
510    // /// Tamil
511    // #[cfg(feature = "ta")]
512    // Ta,
513    // /// Telugu
514    // #[cfg(feature = "te")]
515    // Te,
516    // /// Tajik
517    // #[cfg(feature = "tg")]
518    // Tg,
519    // /// Thai
520    // #[cfg(feature = "th")]
521    // Th,
522    // /// Tigrinya
523    // #[cfg(feature = "ti")]
524    // Ti,
525    // /// Turkmen
526    // #[cfg(feature = "tk")]
527    // Tk,
528    // /// Tagalog
529    // #[cfg(feature = "tl")]
530    // Tl,
531    // /// Tswana
532    // #[cfg(feature = "tn")]
533    // Tn,
534    // /// Tonga
535    // #[cfg(feature = "to")]
536    // To,
537    // /// Turkish
538    // #[cfg(feature = "tr")]
539    // Tr,
540    // /// Tsonga
541    // #[cfg(feature = "ts")]
542    // Ts,
543    // /// Tatar
544    // #[cfg(feature = "tt")]
545    // Tt,
546    // /// Twi
547    // #[cfg(feature = "tw")]
548    // Tw,
549    // /// Tahitian
550    // #[cfg(feature = "ty")]
551    // Ty,
552    // /// Uyghur
553    // #[cfg(feature = "ug")]
554    // Ug,
555    // /// Ukrainian
556    // #[cfg(feature = "uk")]
557    // Uk,
558    // /// Urdu
559    // #[cfg(feature = "ur")]
560    // Ur,
561    // /// Uzbek
562    // #[cfg(feature = "uz")]
563    // Uz,
564    // /// Venda
565    // #[cfg(feature = "ve")]
566    // Ve,
567    // /// Vietnamese
568    // #[cfg(feature = "vi")]
569    // Vi,
570    // /// Volapük
571    // #[cfg(feature = "vo")]
572    // Vo,
573    // /// Walloon
574    // #[cfg(feature = "wa")]
575    // Wa,
576    // /// Wolof
577    // #[cfg(feature = "wo")]
578    // Wo,
579    // /// Xhosa
580    // #[cfg(feature = "xh")]
581    // Xh,
582    // /// Yiddish
583    // #[cfg(feature = "yi")]
584    // Yi,
585    // /// Yoruba
586    // #[cfg(feature = "yo")]
587    // Yo,
588    // /// Zhuang
589    // #[cfg(feature = "za")]
590    // Za,
591    // /// Chinese
592    // #[cfg(feature = "zh")]
593    // Zh,
594    // /// Zulu
595    // #[cfg(feature = "zu")]
596    // Zu,
597}
598
599#[cfg(feature = "alloc")]
600impl alloc::fmt::Display for Lang {
601    fn fmt(&self, f: &mut alloc::fmt::Formatter<'_>) -> alloc::fmt::Result {
602        write!(f, "{:?}", self)
603    }
604}