blib/lib/SDL2/locale.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 35 CC 1 SCAR 6.9
CC
1
Cov
0%
language
2.0
country
2.0
BEGIN
2.0
CRAP 2.0
1 package SDL2::locale {
2 use strictures 2;
3 use SDL2::Utils;
4 use experimental 'signatures';
5 #
6 use SDL2::stdinc;
7 use SDL2::error;
8 #
9 package SDL2::Locale {
10 use SDL2::Utils;
11 our $TYPE = has
12 _language => 'opaque',
13 _country => 'opaque';
14  
15 sub language {
16 ffi->cast( 'opaque', 'string', $_[0]->_language );
17 }
18  
19 sub country {
20 ffi->cast( 'opaque', 'string', $_[0]->_country );
21 }
22 our $LIST = FFI::C::ArrayDef->new(
23 ffi(),
24 name => 'LocaleList_t',
25 class => 'LocaleList',
26 members => [$SDL2::Locale::TYPE]
27 );
28 };
29 attach locale => { SDL_GetPreferredLocales => [ [], 'LocaleList_t' ] };
30  
31 =encoding utf-8
32  
33 =head1 NAME
34  
35 SDL2::locale - SDL Locale Services
36  
37 =head1 SYNOPSIS
38  
39 use SDL2 qw[:locale];
40 my $locale = SDL_GetPreferredLocales( )->[0];
41  
42 =head1 DESCRIPTION
43  
44 SDL2::locale represents the user's preferred locale.
45  
46 =head1 Functions
47  
48 These may be imported by name or with the C<:locale> tag.
49  
50 =head2 C<SDL_GetPreferredLocales( )>
51  
52 Report the user's preferred locale.
53  
54 my $locale = SDL_GetPreferredLocales( )->[0];
55 warn $locale->language;
56 warn $locale->country;
57  
58 This returns an array of L<SDL2::Locale> structs, the final item zeroed out.
59  
60 Returned language strings are in the format xx, where 'xx' is an ISO-639
61 language specifier (such as "en" for English, "de" for German, etc). Country
62 strings are in the format YY, where "YY" is an ISO-3166 country code (such as
63 "US" for the United States, "CA" for Canada, etc). Country might be NULL if
64 there's no specific guidance on them (so you might get C<{ "en", "US" }> for
65 American English, but C<{ "en", undef }> means "English language,
66 generically"). Language strings are never C<undef>, except to terminate the
67 array.
68  
69 Please note that not all of these strings are 2 characters; some are three or
70 more.
71  
72 The returned list of locales are in the order of the user's preference. For
73 example, a German citizen that is fluent in US English and knows enough
74 Japanese to navigate around Tokyo might have a list like: C<[ "de", "en_US",
75 "jp", undef ]>. Someone from England might prefer British English (where
76 "color" is spelled "colour", etc), but will settle for anything like it: C<[
77 "en_GB", "en", undef ]>.
78  
79 This function returns C<undef> on error, including when the platform does not
80 supply this information at all.
81  
82 This might be a "slow" call that has to query the operating system. It's best
83 to ask for this once and save the results. However, this list can change,
84 usually because the user has changed a system preference outside of your
85 program; SDL will send an C<SDL_LOCALECHANGED> event in this case, if possible,
86 and you can call this function again to get an updated copy of preferred
87 locales.
88  
89 Returns L<an array|FFI::C::Array> of locales, terminated with a locale with an
90 C<undef> language field. Will return C<undef> on error.
91  
92 =head1 LICENSE
93  
94 Copyright (C) Sanko Robinson.
95  
96 This library is free software; you can redistribute it and/or modify it under
97 the terms found in the Artistic License 2. Other copyrights, terms, and
98 conditions may apply to data transmitted through this module.
99  
100 =head1 AUTHOR
101  
102 Sanko Robinson E<lt>sanko@cpan.orgE<gt>
103  
104 =begin stopwords
105  
106 structs xx
107  
108 =end stopwords
109  
110 =cut
111  
112 };
113 1;