You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use Cro::WebApp::Form;
enumLang <DE EN ES GE PL>;
enumCountry <DEU USA ESP GEO PLN>;
enumStrings (user-name =>"user-name", password =>"password", name =>"name", company-name =>"company-name", yes =>"yes", no=>"no", enter =>"enter", cancel =>"cancel", escape =>"escape", submit =>"submit");
my%STRINGS=user-name => { GE =>"მომხმარებლის სახელი", EN =>"user name" },
password => { GE =>"პაროლი", EN =>"password" },
name => { GE =>"სახელი", EN =>"name" },
company-name => { GE =>"კომპანიის სახელი", EN =>"company name" },
yes => { GE =>"დიახ", EN =>"yes" },
no=> { GE =>"არა", EN =>"no" },
enter => { GE =>"შედი", EN =>"enter" },
cancel => { GE =>"გააუქმოს", EN =>"cancel" },
escape => { GE =>"გაქცევა", EN =>"escape" },
submit => { GE =>"წარადგინოს", EN =>"submit" };
roleL10N::Formdoes Cro::WebApp::Form isexport {
has Lang $.langisrwis hidden;
method!calculate-label($attr) {
my$label=dowith$attr.?webapp-form-label {
# Explicitly provided labelreturn%STRINGS{$_}{$!lang} ifso%STRINGS{$_}{$!lang};
return$_;
} else {
# Fall back to mangling the attribute name.my$attr-name=$attr.name.substr(2);
return%STRINGS{$attr-name}{$!lang} ifso%STRINGS{$attr-name}{$!lang};
my@words=$attr-name.split('-');
@words[0] .= tclc;
return@words.join('');
};
return$label;
}
methodempty(Lang $lang) {
my$form=self.CREATE;
$form.lang =$lang;
return$form;
}
}
subl10n(Lang $lang, $str-->Str) isexport {
return%STRINGS{$str}{$lang} ifso%STRINGS{$str}{$lang};
return"undefined";
}
and then in some other file
use Cro::WebApp::Form;
classLoginFormdoes L10N::Form { has$.user-nameis label(Strings::name) };
LoginForm.empty(GE).HTML-RENDER-DATA;
gives result
{controls => [{label => სახელი, name => user-name, required => False, type => text} {label => Lang, name => lang, required => False, type => hidden, value => GE}], was-validated => False}
{controls => [{label => მომხმარებლის სახელი, name => user-name, required => True, type => text} {label => პაროლი, name => password, required => True, type => text} {label => კომპანიის სახელი, name => company-name, required => False, type => text} {label => Lang, name => lang, required => False, type => hidden, value => GE}], was-validated => False}
The text was updated successfully, but these errors were encountered:
Maybe it's ugly but for me forks just fine
and then in some other file
gives result
and
gives
The text was updated successfully, but these errors were encountered: