| 1 | package Serge::Engine::Plugin::limit_languages; | ||
| 2 | 1 | ▶ | use parent Serge::Plugin::Base::Callback; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | |||
| 4 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | ▶ | use Config::Neat::Inheritable; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use Config::Neat::Array; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use Data::Dumper; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 1 | our %limitLanguages; | |
| 11 | 1 | our %orphaned; | |
| 12 | |||
| 13 | sub name { | ||
| 14 | 0 | ▶ | return 'Limit destination languages on a per-file basis'; |
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 15 | } | ||
| 16 | |||
| 17 | sub init { | ||
| 18 | 0 | ▶ | my $self = shift; |
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 19 | |||
| 20 | 0 | $self->SUPER::init(@_); | |
| 21 | |||
| 22 | 0 | $self->merge_schema({ | |
| 23 | debug => 'BOOLEAN', | ||
| 24 | |||
| 25 | if => {'' => 'LIST', | ||
| 26 | |||
| 27 | '*' => { | ||
| 28 | file_matches => 'ARRAY', | ||
| 29 | file_doesnt_match => 'ARRAY', | ||
| 30 | |||
| 31 | content_matches => 'ARRAY', | ||
| 32 | content_doesnt_match => 'ARRAY', | ||
| 33 | |||
| 34 | then => { | ||
| 35 | split_by => 'STRING', | ||
| 36 | |||
| 37 | limit_languages => 'ARRAY', | ||
| 38 | include_languages => 'ARRAY', | ||
| 39 | exclude_languages => 'ARRAY', | ||
| 40 | |||
| 41 | limit_to_matched_languages => 'BOOLEAN', | ||
| 42 | include_matched_languages => 'BOOLEAN', | ||
| 43 | exclude_matched_languages => 'BOOLEAN', | ||
| 44 | |||
| 45 | exclude_all_languages => 'BOOLEAN', | ||
| 46 | include_all_languages => 'BOOLEAN', | ||
| 47 | } | ||
| 48 | |||
| 49 | }, | ||
| 50 | }, | ||
| 51 | }); | ||
| 52 | |||
| 53 | 0 | $self->add({ | |
| 54 | after_load_source_file_for_processing => \&after_load_source_file_for_processing, | ||
| 55 | is_file_orphaned => \&is_file_orphaned, | ||
| 56 | can_process_source_file => \&can_process_source_file, | ||
| 57 | can_process_ts_file => \&can_process_file_lang, | ||
| 58 | can_generate_ts_file => \&can_process_file_lang, | ||
| 59 | can_generate_localized_file => \&can_process_file_lang | ||
| 60 | }); | ||
| 61 | |||
| 62 | 0 | my $c = Config::Neat::Inheritable->new(); | |
| 63 | 0 | my $data = <<__END__; | |
| 64 | |||
| 65 | if | ||
| 66 | { | ||
| 67 | # generic rule to limit translation only to a certain set of languages | ||
| 68 | # example: L10N_LIMIT_DESTINATION_LANGUAGES=es-latam,zh-tw | ||
| 69 | content_matches \\bL10N_LIMIT_DESTINATION_LANGUAGES=([\\w,-]*\\w+)? | ||
| 70 | |||
| 71 | then | ||
| 72 | { | ||
| 73 | split_by , | ||
| 74 | limit_to_matched_languages | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 78 | if | ||
| 79 | { | ||
| 80 | # generic rule to exclude a certain set of languages | ||
| 81 | # example: L10N_EXCLUDE_DESTINATION_LANGUAGES=ar | ||
| 82 | content_matches \\bL10N_EXCLUDE_DESTINATION_LANGUAGES=([\\w,-]*\\w+)? | ||
| 83 | |||
| 84 | then | ||
| 85 | { | ||
| 86 | split_by , | ||
| 87 | exclude_matched_languages | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 91 | __END__ | ||