-
Notifications
You must be signed in to change notification settings - Fork 0
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
Topic 6/ Frontend Add alerts related translations #28
Conversation
c542853
to
24b0480
Compare
@imenattatra my comments small think here as well when trying to add a destination and no choice is available do you know if there is anything we can do about these ? if not - please do not consider as a priority. At this time it is only a question, and does not need to be addressed in terms of implementation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @imenattatra for pushing this through. This i18next
was a good choice from the API I'm seeing here. I added some comments to better understand it, but I feel we should stick with one strategy on how to do translation and stick with it.
Question: would it be possible to define this t = useTranslation("Alerts")
in a single place that can be used by every component? Like a type of global variable?
@@ -113,12 +117,12 @@ class Alert extends React.Component { | |||
|
|||
return AlertService.save(alert) | |||
.then(alert => { | |||
notification.success("Saved."); | |||
notification.success(i18next.t("Saved.")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have the Alerts:
prefix here too?
notification.success(i18next.t("Saved.")); | |
notification.success(i18next.t("Alerts:Saved.")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because "Saved." is used in many places across the app, i did put it under the common
namespace which is set as default, so we don't need to write common:
@@ -56,32 +58,32 @@ export default class AlertEdit extends React.Component { | |||
<DynamicComponent name="AlertEdit.HeaderExtra" alert={alert} /> | |||
<Button className="m-r-5" onClick={() => this.cancel()}> | |||
<i className="fa fa-times m-r-5" aria-hidden="true" /> | |||
Cancel | |||
{i18next.t("Cancel")} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{i18next.t("Cancel")} | |
{i18next.t("Alerts:Cancel")} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for Cancel
as for Saved.
, it is used in many places across the app, i did put it under the common
namespace which is set as default, so we don't need to write common:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhhhhh ok, got it! Thanks for the explanation 🙏
</Button> | ||
<Button type="primary" onClick={() => this.save()}> | ||
{saving ? ( | ||
<span role="status" aria-live="polite" aria-relevant="additions removals"> | ||
<i className="fa fa-spinner fa-pulse m-r-5" aria-hidden="true" /> | ||
<span className="sr-only">Saving...</span> | ||
<span className="sr-only">{i18next.t("Saving...")}</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<span className="sr-only">{i18next.t("Saving...")}</span> | |
<span className="sr-only">{i18next.t("Alerts:Saving")}...</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will remove the three dots and other characters from the translated text in a separate PR since these Saving..
and (Help)
for example are used across the app at many places... this is also why you find no namespace prefix to them since they are in the common
default namespace
Setup Instructions <i className="fa fa-question-circle" aria-hidden="true" /> | ||
<span className="sr-only">(help)</span> | ||
{i18next.t("Alerts:Setup Instructions")} <i className="fa fa-question-circle" aria-hidden="true" /> | ||
<span className="sr-only">{i18next.t("(help)")}</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's nice to leave non-translatable characters like (
or ...
outside of the translation string. This will make it simpler for people to add translation since they won't be worry about the context where such texts are being used.
<span className="sr-only">{i18next.t("(help)")}</span> | |
<span className="sr-only">({i18next.t("Alerts:help")})</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, (same reply as previous one :D ) I will remove the three dots and other characters from the translated text in a separate PR since these Saving..
and (Help)
for example are used across the app at many places... this is also why you find no namespace prefix to them since they are in the common
default namespace
@@ -79,16 +81,16 @@ export default class AlertNew extends React.Component { | |||
{saving && ( | |||
<span role="status" aria-live="polite" aria-relevant="additions removals"> | |||
<i className="fa fa-spinner fa-pulse m-r-5" aria-hidden="true" /> | |||
<span className="sr-only">Saving...</span> | |||
<span className="sr-only">{i18next.t("Saving...")}</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<span className="sr-only">{i18next.t("Saving...")}</span> | |
<span className="sr-only">{i18next.t("Alerts:Saving")}...</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as previous one also, thanks
<Button | ||
data-test="ShowAddAlertSubDialog" | ||
type="primary" | ||
size="small" | ||
className="add-button" | ||
onClick={this.showAddAlertSubDialog}> | ||
<i className="fa fa-plus f-12 m-r-5" aria-hidden="true" /> Add | ||
<i className="fa fa-plus f-12 m-r-5" aria-hidden="true" /> {i18next.t("Add")} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<i className="fa fa-plus f-12 m-r-5" aria-hidden="true" /> {i18next.t("Add")} | |
<i className="fa fa-plus f-12 m-r-5" aria-hidden="true" /> {i18next.t("Alerts:Add")} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for Add
@@ -12,6 +14,7 @@ import EllipsisOutlinedIcon from "@ant-design/icons/EllipsisOutlined"; | |||
import PlainButton from "@/components/PlainButton"; | |||
|
|||
export default function MenuButton({ doDelete, canEdit, mute, unmute, muted }) { | |||
const { t } = useTranslation(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { t } = useTranslation(); | |
const { t } = useTranslation("Alerts"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here i found myself between deciding either to use const { t } = useTranslation("Alerts"); but then i will need to find a solution for many expressions that fall in the case of common
namespace or just not specify the prefix earlier and specify it only when needed... I took the second decision
title: t("Alerts:Delete Alert"), | ||
content: t("Alerts:Are you sure you want to delete this alert?"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we've defined the t
object as the translation form alerts, I feel we don't need this prefix here. Is it correct?
title: t("Alerts:Delete Alert"), | |
content: t("Alerts:Are you sure you want to delete this alert?"), | |
title: t("Delete Alert"), | |
content: t("Are you sure you want to delete this alert?"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is related to the previous comment
<PlainButton onClick={() => execute(unmute)}>{t("Alerts:Unmute Notifications")}</PlainButton> | ||
) : ( | ||
<PlainButton onClick={() => execute(mute)}>Mute Notifications</PlainButton> | ||
<PlainButton onClick={() => execute(mute)}>{t("Alerts:Mute Notifications")}</PlainButton> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
<Trans i18nKey="Alerts:just_once"> | ||
Just once <em>until back to normal</em> | ||
</Trans> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this as a 3rd approach on defining translations. I personally would stick with one of the previous one. If I understood it correctly, this Trans
block requires this id which will be used to find the translated content. This can be harder for non-developer people to add translation because it requires they to navigate through the code to find the matching i18nKey
and add the translated content.
Is this different because, within the translated context, we have this em
tags?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used Trans
because it is designed for jsx
code translation , so definitely it works as expected here. Also useTranslation or simple i18next.t does not work as expected with these jsx
especially when it has nested content such as <em>until back to normal</em>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non developer people can check the english file, since it will include the word per word translation .. we don't have much of these cases anyway
I corrected the two cases above : the time parameter and the alert destination case, but for the status, i don't want to touch it now because they are setting it from the backend but then i found out places where they check against the values, so if i touch one place and not everywhere something my stop working as it should , i prefer to do it separately later. |
@helenalebreton and @berinhard I created this issue so that i don't forget about alerts status and the characters in translation : https://github.com/metr-systems/backlog/issues/3722, so that I can merge this PR :D , what do you think about it? |
@imenattatra please consider it no priority for now. We will take a look at it only later after we looked into other UI isseus (not linked to translation) from redash |
Nice strategy here @imenattatra. I'm good with merging this PR if pending improvements are mapped to other issues. |
Related to the translation project : https://github.com/metr-systems/backlog/issues/3476
What type of PR is this?
This is related to redash translation project and covers texts related to Alerts.
How is this tested?
This is currently deployed to staging
Follow-up: