fix(translate): fix provider usage

This commit is contained in:
2024-07-07 15:16:16 +03:00
parent 0a6f7841e1
commit 8f30eff1dd
3 changed files with 11 additions and 13 deletions

View File

@@ -3,30 +3,33 @@ package hw.translate;
import hw.provider.Provider;
abstract TranslateString(String) from String to String {
@:provide var translate:ITranslate;
inline public function new(value:String, args:Array<Dynamic> = null) {
if (args != null) {
this = Provider.get(ITranslate).format(value, args);
this = translate.format(value, args);
} else {
this = Provider.get(ITranslate).get(value);
this = translate.get(value);
}
}
}
abstract TranslateArrayString(String) from String to String {
@:provide var translate:ITranslate;
inline public function new(value:String, index:Int) {
this = Provider.get(ITranslate).getArray(value)[index];
this = translate.getArray(value)[index];
}
}
abstract TranslatePluralString(String) from String to String {
@:provide var translate:ITranslate;
inline public function new(value:String, num:Int, args:Array<Dynamic> = null) {
if (args != null) {
this = Provider.get(ITranslate).formatPlurar(value, num, args);
this = translate.formatPlurar(value, num, args);
} else {
this = Provider.get(ITranslate).getPlural(value, num);
this = translate.getPlural(value, num);
}
}
}