iljapostnovs / VSCodeUI5Plugin

Visual Studio Code Extension for UI5 Development
Apache License 2.0
61 stars 6 forks source link

Feature request: Bulk export to i18n #361

Closed mateusz-matyjaszczyk closed 1 year ago

mateusz-matyjaszczyk commented 1 year ago

Describe the feature As we all know there is a command "UI5: Export to i18n" or simply F4 shortcut we can export texts to i18n and ID gets created there dynamically, on top of that there is additional config that can be done via "askUserToConfirmI18nId" where you won't even need to confirm generated ID. I would like to ask if there is a possibility to add a command "Export all texts to i18n" where simply all texts will be exported so we won't need to do it text by text.

iljapostnovs commented 1 year ago

Hi,

I was thinking about it a long time ago, but the issue is that it is impossible to distinguish which texts should be put to i18n and which shouldn't. Example: sap.m.ColumnListItem -> highlight, according to API, data type is a string, so, judging by the data type it should be put into translations, but in real life it shouldn't. So unless you have some ideas how to implement it, I would say it is impossible to do automatically.

mateusz-matyjaszczyk commented 1 year ago

Hey,

I think it is fair to do it only for actually displayed texts -> which would mean only sap.m.Text -> Text, sap.m.Label -> text, sap.m.Input -> Placeholder

iljapostnovs commented 1 year ago

Hey,

I think it is fair to do it only for actually displayed texts -> which would mean only sap.m.Text -> Text, sap.m.Label -> text, sap.m.Input -> Placeholder

Hi. I don't think it would be fair, because that's not even near to the number of control properties that requires translation.

Examples: sap.m.ObjectHeader -> intro, title sap.m.DisplayListItem -> label, value sap.m.ListItemBase-> highlightText sap.m.Button-> text sap.m.SelectDialog -> noDataText, confirmButtonText, searchPlaceholder, title etc etc.

I can see already that people will not be happy a lot for the functionality which is working poorly :)

mateusz-matyjaszczyk commented 1 year ago

Hey, sorry for typo. I mean "only things like..." but of course not limited. I think fair assessment is this part "do it only for actually displayed texts"

iljapostnovs commented 1 year ago

How exactly it is possible to determine which Control properties are "actually displayed texts"?

mateusz-matyjaszczyk commented 1 year ago

I don't think it is possible. I think this should be "hard-coded" via config. Maybe it would be a setting where you can add:

"bulkExporti18n": {
"controlClass": {
"property": true
}
}

i.e.

"bulkExporti18n": {
"sap.m.Text": {
"text": true
},
"sap.m.Input":{
"placeholder": true
},
"sap.m.Button":{
"text": true,
"tooltip": true
}
}

by default those can be all false, or maybe set-up some "pre-config", but allow to override it. As long as someone can specify if he/she want specific property to be taken care with bulkExport I think it makes sense.

If this idea is just stupid - please say so, its all fine 😉

iljapostnovs commented 1 year ago

That will be hell of a big config to support for everyone individually :)

iljapostnovs commented 1 year ago

The idea is not stupid, it's actually the only one possible, but what bothers me that it will take a lot of effort for everyone to support it. Moreover, it means that everyone can't trust that the command actually exports everything they need and still people will need to recheck the result everytime.

mateusz-matyjaszczyk commented 1 year ago

Yes, it would have to be initial configuration provided by you that someone can eventually override.

Another idea: Are you able to read from the metadata if property is enum or not? Maybe if something is a string and is not an enum it could be translated. This would take care of things like previously mentioned sap.m.ColumnListItem -> highlight - which is an enum: "Valid values for the highlight property are values of the enumerations sap.ui.core.MessageType or sap.ui.core.IndicationColor."

iljapostnovs commented 1 year ago

Yes, it would have to be initial configuration provided by you that someone can eventually override.

Another idea: Are you able to read from the metadata if property is enum or not? Maybe if something is a string and is not an enum it could be translated. This would take care of things like previously mentioned sap.m.ColumnListItem -> highlight - which is an enum: "Valid values for the highlight property are values of the enumerations sap.ui.core.MessageType or sap.ui.core.IndicationColor."

That's exactly the issue, technically highlight is not enum, but string. I can read enums, but according to the API it's not an enum.

iljapostnovs commented 1 year ago

image This is enum

image This is not.

mateusz-matyjaszczyk commented 1 year ago

Okay... so they said in the property description that this is an enum but technically it is just a string...

Then no other way besides the config mentioned above. Please close the request if you think it is not worth the time investment - I personally think now it is not worth time investment...

iljapostnovs commented 1 year ago

Hi.

Well, I decided to give it a try and hope that people will help to improve default values in the future :) Please check v1.12.0