Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translating availabilities/status for Domains/Servers/Deploys #2323

Merged
merged 1 commit into from
Oct 24, 2017

Conversation

xeviknal
Copy link
Member

@xeviknal xeviknal commented Oct 9, 2017

Status literals of Domain/Server/Deployment translated and titleized.

Deployment status:
translate-deployment

Domain state:
translate-domain

Server state:
translate-server

@martinpovolny
Copy link
Member

@xeviknal : how do these strings get to the catalog? Are we sure all of them are in the catalog? Thx!

@mzazrivec
Copy link
Contributor

@xeviknal Also, what's the point of calling to_s() on a string? Why is the result of _().to_s being
titleized?

@xeviknal
Copy link
Member Author

@martinpovolny two of the statuses are merged to Master (Server and Deployment). Domain availability is pending to merge (ManageIQ/manageiq-providers-hawkular#67).

@mzazrivec _(nil) #=> nil then needs a protection to nil access. It could happen when domain is created for first time, since properties by default is an empty hash. Calling to to_s makes it return an empty string. Another option, would be to call .try(:titleize).

Thanks for comments guys!

@martinpovolny
Copy link
Member

@xeviknal : please, take a look at http://manageiq.org/docs/guides/i18n

the problem is the strings you are passwing throught i18n will not be in the gettext catalog unless you mark those somewhere the string collecting task would reach them

@mzazrivec
Copy link
Contributor

Also, you should not be doing any more transformations with the strings coming out of _(). These
should really just be presented the way they come out. I.e. things should be done in such a way
that no to_s() nor titleize() should be needed here.

@xeviknal
Copy link
Member Author

@martinpovolny then it means that I have to explicitly set the msgid for each translation. I can't use dynamic values to translate.

if value == 'Disabled'
   _('Disabled')
elsif value == 'Enabled'
   _('Enabled')
else
  _('Unknowkn')
end

@mzazrivec I understand what you mean. We fully trust on what translators do, and we don't have to manipulate anything from there. 👍

@abonas
Copy link
Member

abonas commented Oct 15, 2017

@miq-bot add_label middleware

@martinpovolny
Copy link
Member

I am not sure what is the best pattern to use here.

A case statement is probably quite ok or maybe something like:

SERVER_STATES = {
 'Disabled' => N_('Disabled'),
 'Enabled' => N_('Enabled'),
 'Unknown' => N_('Unknown')
}.freeze

def translated_server_status(status)
  key = SERVER_STATES.key?(status) ? status : 'Unknown'
  _(SERVER_STATES[key])
end

Or you might leave the unknown message untranslated, that might be the best option for the user.

def translated_server_status(status)
  SERVER_STATES.key?(status) ?  _(SERVER_STATES[status]) : status
end

I'd refer to @mzazrivec as our i18n expert ;-)

@xeviknal
Copy link
Member Author

@martinpovolny okay, apart from the pattern followed, I got how the system works now. 🎉
One other thing is, is there a common helper where to put common logic? I think translated_server_status method could be shared.

@martinpovolny
Copy link
Member

martinpovolny commented Oct 16, 2017

@xeviknal : the textual_summary files are actually helpers. If you need to share code bettween those files, there are mixing included in several:
grep include $(find . -name 'textual_summary*')

So you might reuse one or create a new one if needed.

@abonas
Copy link
Member

abonas commented Oct 23, 2017

@xeviknal where does this PR stand? any more changes needed or it can be merged?

@xeviknal xeviknal changed the title Translate and titleize Domain/Deployment/Server's statuses Translating availabilities/status for Domains/Servers/Deploys Oct 23, 2017
@xeviknal
Copy link
Member Author

@martinpovolny @mzazrivec could you please check it out?
Thanks for helping me get onboarded 🥇

@xeviknal xeviknal force-pushed the middleware-status-translate branch 3 times, most recently from ec3a002 to 63eaae8 Compare October 24, 2017 10:36
@miq-bot
Copy link
Member

miq-bot commented Oct 24, 2017

Checked commit xeviknal@d40de8e with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0
5 files checked, 0 offenses detected
Everything looks fine. 🍰

@mzazrivec mzazrivec added this to the Sprint 72 Ending Oct 30, 2017 milestone Oct 24, 2017
@mzazrivec mzazrivec merged commit 7ae468a into ManageIQ:master Oct 24, 2017
israel-hdez added a commit to israel-hdez/manageiq-ui-classic that referenced this pull request Jan 4, 2018
…tus-translate"

This reverts commit 7ae468a, reversing
changes made to 406cfc4.

...To remove the mixin of availability translations
israel-hdez added a commit to israel-hdez/manageiq-ui-classic that referenced this pull request Jan 11, 2018
…tus-translate"

This reverts commit 7ae468a, reversing
changes made to 406cfc4.

...To remove the mixin of availability translations
israel-hdez added a commit to israel-hdez/manageiq-ui-classic that referenced this pull request Jan 15, 2018
…tus-translate"

This reverts commit 7ae468a, reversing
changes made to 406cfc4.

...To remove the mixin of availability translations
israel-hdez added a commit to israel-hdez/manageiq-ui-classic that referenced this pull request Jan 17, 2018
…tus-translate"

This reverts commit 7ae468a, reversing
changes made to 406cfc4.

...To remove the mixin of availability translations
israel-hdez added a commit to israel-hdez/manageiq-ui-classic that referenced this pull request Jan 19, 2018
…tus-translate"

This reverts commit 7ae468a, reversing
changes made to 406cfc4.

...To remove the mixin of availability translations
israel-hdez added a commit to israel-hdez/manageiq-ui-classic that referenced this pull request Jan 22, 2018
…tus-translate"

This reverts commit 7ae468a, reversing
changes made to 406cfc4.

...To remove the mixin of availability translations
israel-hdez added a commit to israel-hdez/manageiq-ui-classic that referenced this pull request Jan 24, 2018
…tus-translate"

This reverts commit 7ae468a, reversing
changes made to 406cfc4.

...To remove the mixin of availability translations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants