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

@@ -4,7 +4,7 @@
"license": "MIT",
"tags": ["view", "layout", "template"],
"description": "View framework.",
"version": "2.1.0",
"version": "2.1.1",
"releasenote": "Update.",
"contributors": ["shmyga"],
"classPath": "src/main",

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);
}
}
}

View File

@@ -14,20 +14,15 @@ class ButtonImageView extends ButtonView {
public function new(image:BitmapData = null) {
super();
skin = bitmapSkin;
if (image != null) {
this.image = image;
}
}
override private function set_skin(value:SkinSet):SkinSet {
value = value.slice(0);
value.unshift(bitmapSkin);
return super.set_skin(value);
}
private function set_image(value:BitmapData):BitmapData {
if (image != value) {
setContentSize(value.width, value.height, "image");
setSize(value.width, value.height, "image");
image = value;
bitmapSkin.image = image;
toRedraw();