📄 i18n::langtags.3
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings. \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote. \*(C+ will.\" give a nicer C++. Capital omega is used to do unbreakable dashes and.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "I18N::LangTags 3".TH I18N::LangTags 3 "2007-12-18" "perl v5.10.0" "Perl Programmers Reference Guide".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"I18N::LangTags \- functions for dealing with RFC3066\-style language tags.SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 1\& use I18N::LangTags();.Ve.PP\&...or specify whichever of those functions you want to import, like so:.PP.Vb 1\& use I18N::LangTags qw(implicate_supers similarity_language_tag);.Ve.PPAll the exportable functions are listed below \*(-- you're free to importonly some, or none at all. By default, none are imported. If yousay:.PP.Vb 1\& use I18N::LangTags qw(:ALL).Ve.PP\&...then all are exported. (This saves you from having to usesomething less obvious like \f(CW\*(C`use I18N::LangTags qw(/./)\*(C'\fR.).PPIf you don't import any of these functions, assume a \f(CW&I18N::LangTags::\fRin front of all the function names in the following examples..SH "DESCRIPTION".IX Header "DESCRIPTION"Language tags are a formalism, described in \s-1RFC\s0 3066 (obsoleting1766), for declaring what language form (language and possiblydialect) a given chunk of information is in..PPThis library provides functions for common tasks involving languagetags as they are needed in a variety of protocols and applications..PPPlease see the \*(L"See Also\*(R" references for a thorough explanationof how to correctly use language tags..IP "\(bu" 4the function is_language_tag($lang1).SpReturns true iff \f(CW$lang1\fR is a formally valid language tag..Sp.Vb 3\& is_language_tag("fr") is TRUE\& is_language_tag("x\-jicarilla") is FALSE\& (Subtags can be 8 chars long at most \-\- \*(Aqjicarilla\*(Aq is 9)\&\& is_language_tag("sgn\-US") is TRUE\& (That\*(Aqs American Sign Language)\&\& is_language_tag("i\-Klikitat") is TRUE\& (True without regard to the fact noone has actually\& registered Klikitat \-\- it\*(Aqs a formally valid tag)\&\& is_language_tag("fr\-patois") is TRUE\& (Formally valid \-\- altho descriptively weak!)\&\& is_language_tag("Spanish") is FALSE\& is_language_tag("french\-patois") is FALSE\& (No good \-\- first subtag has to match\& /^([xXiI]|[a\-zA\-Z]{2,3})$/ \-\- see RFC3066)\&\& is_language_tag("x\-borg\-prot2532") is TRUE\& (Yes, subtags can contain digits, as of RFC3066).Ve.IP "\(bu" 4the function extract_language_tags($whatever).SpReturns a list of whatever looks like formally valid language tagsin \f(CW$whatever\fR. Not very smart, so don't get too creative withwhat you want to feed it..Sp.Vb 2\& extract_language_tags("fr, fr\-ca, i\-mingo")\& returns: (\*(Aqfr\*(Aq, \*(Aqfr\-ca\*(Aq, \*(Aqi\-mingo\*(Aq)\&\& extract_language_tags("It\*(Aqs like this: I\*(Aqm in fr \-\- French!")\& returns: (\*(AqIt\*(Aq, \*(Aqin\*(Aq, \*(Aqfr\*(Aq)\& (So don\*(Aqt just feed it any old thing.).Ve.SpThe output is untainted. If you don't know what tainting is,don't worry about it..IP "\(bu" 4the function same_language_tag($lang1, \f(CW$lang2\fR).SpReturns true iff \f(CW$lang1\fR and \f(CW$lang2\fR are acceptable variant tagsrepresenting the same language-form..Sp.Vb 10\& same_language_tag(\*(Aqx\-kadara\*(Aq, \*(Aqi\-kadara\*(Aq) is TRUE\& (The x/i\- alternation doesn\*(Aqt matter)\& same_language_tag(\*(AqX\-KADARA\*(Aq, \*(Aqi\-kadara\*(Aq) is TRUE\& (...and neither does case)\& same_language_tag(\*(Aqen\*(Aq, \*(Aqen\-US\*(Aq) is FALSE\& (all\-English is not the SAME as US English)\& same_language_tag(\*(Aqx\-kadara\*(Aq, \*(Aqx\-kadar\*(Aq) is FALSE\& (these are totally unrelated tags)\& same_language_tag(\*(Aqno\-bok\*(Aq, \*(Aqnb\*(Aq) is TRUE\& (no\-bok is a legacy tag for nb (Norwegian Bokmal)).Ve.Sp\&\f(CW\*(C`same_language_tag\*(C'\fR works by just seeing whether\&\f(CW\*(C`encode_language_tag($lang1)\*(C'\fR is the same as\&\f(CW\*(C`encode_language_tag($lang2)\*(C'\fR..Sp(Yes, I know this function is named a bit oddly. Call it historicreasons.).IP "\(bu" 4the function similarity_language_tag($lang1, \f(CW$lang2\fR).SpReturns an integer representing the degree of similarity betweentags \f(CW$lang1\fR and \f(CW$lang2\fR (the order of which does not matter), wheresimilarity is the number of common elements on the left,without regard to case and to x/i\- alternation..Sp.Vb 4\& similarity_language_tag(\*(Aqfr\*(Aq, \*(Aqfr\-ca\*(Aq) is 1\& (one element in common)\& similarity_language_tag(\*(Aqfr\-ca\*(Aq, \*(Aqfr\-FR\*(Aq) is 1\& (one element in common)\&\& similarity_language_tag(\*(Aqfr\-CA\-joual\*(Aq,\& \*(Aqfr\-CA\-PEI\*(Aq) is 2\& similarity_language_tag(\*(Aqfr\-CA\-joual\*(Aq, \*(Aqfr\-CA\*(Aq) is 2\& (two elements in common)\&\& similarity_language_tag(\*(Aqx\-kadara\*(Aq, \*(Aqi\-kadara\*(Aq) is 1\& (x/i\- doesn\*(Aqt matter)\&\& similarity_language_tag(\*(Aqen\*(Aq, \*(Aqx\-kadar\*(Aq) is 0\& similarity_language_tag(\*(Aqx\-kadara\*(Aq, \*(Aqx\-kadar\*(Aq) is 0\& (unrelated tags \-\- no similarity)\&\& similarity_language_tag(\*(Aqi\-cree\-syllabic\*(Aq,\& \*(Aqi\-cherokee\-syllabic\*(Aq) is 0\& (no B<leftmost> elements in common!).Ve.IP "\(bu" 4the function is_dialect_of($lang1, \f(CW$lang2\fR).SpReturns true iff language tag \f(CW$lang1\fR represents a subform oflanguage tag \f(CW$lang2\fR..Sp\&\fBGet the order right! It doesn't work the other way around!\fR.Sp.Vb 2\& is_dialect_of(\*(Aqen\-US\*(Aq, \*(Aqen\*(Aq) is TRUE\& (American English IS a dialect of all\-English)\&\& is_dialect_of(\*(Aqfr\-CA\-joual\*(Aq, \*(Aqfr\-CA\*(Aq) is TRUE\& is_dialect_of(\*(Aqfr\-CA\-joual\*(Aq, \*(Aqfr\*(Aq) is TRUE\& (Joual is a dialect of (a dialect of) French)\&\& is_dialect_of(\*(Aqen\*(Aq, \*(Aqen\-US\*(Aq) is FALSE\& (all\-English is a NOT dialect of American English)\&\& is_dialect_of(\*(Aqfr\*(Aq, \*(Aqen\-CA\*(Aq) is FALSE\&\& is_dialect_of(\*(Aqen\*(Aq, \*(Aqen\*(Aq ) is TRUE\& is_dialect_of(\*(Aqen\-US\*(Aq, \*(Aqen\-US\*(Aq) is TRUE\& (B<Note:> these are degenerate cases)\&\& is_dialect_of(\*(Aqi\-mingo\-tom\*(Aq, \*(Aqx\-Mingo\*(Aq) is TRUE\& (the x/i thing doesn\*(Aqt matter, nor does case)\&\& is_dialect_of(\*(Aqnn\*(Aq, \*(Aqno\*(Aq) is TRUE\& (because \*(Aqnn\*(Aq (New Norse) is aliased to \*(Aqno\-nyn\*(Aq,\& as a special legacy case, and \*(Aqno\-nyn\*(Aq is a\& subform of \*(Aqno\*(Aq (Norwegian)).Ve.IP "\(bu" 4the function super_languages($lang1).SpReturns a list of language tags that are superordinate tags to \f(CW$lang1\fR\&\*(-- it gets this by removing subtags from the end of \f(CW$lang1\fR untilnothing (or just \*(L"i\*(R" or \*(L"x\*(R") is left..Sp.Vb 1\& super_languages("fr\-CA\-joual") is ("fr\-CA", "fr")\&\& super_languages("en\-AU") is ("en")\&\& super_languages("en") is empty\-list, ()\&\& super_languages("i\-cherokee") is empty\-list, ()\& ...not ("i"), which would be illegal as well as pointless..Ve.SpIf \f(CW$lang1\fR is not a valid language tag, returns empty-list ina list context, undef in a scalar context..Sp
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -