fix(translate): fix provider usage
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user