I am very new to this so please bear with me.
I’m trying to change the inner HTML of this span:
<span translate="my_team_tab" class="ng-scope">My Team</span>
on page load.
I would like to change the "My Team" text to "My Event". I’ve been looking for hours and nothing seems to be working. Maybe it’s not possible? Like I said, I’m new and would not know otherwise.
Thank you!
I haven’t been able to try anything because almost all solutions mention using an Id and there is no Id assigned to this element. This code is hardcoded into the system I’m working in so I can’t change the HTML itself.
5
Answers
This will fix the Original Poster particular case only:
Typically, you can change the content using javascript.
You said:
Assuming you’re doing it using javascript it should look something like:
However if this is something that you should do for multiple spans with different texts, it could be helpful to write a generic function for it.
You can do this with CSS if absolutely necessary.
First, I defined a constant for
language
, you may infer the language differently. Then, I defined atranslateMap
with keys representing the values oftranslate
and values representing a map of languages and their value in the given language.Finally, I search for all
translatable
, that is, elements having atranslate
attribute, loop them and if the given element has a translation in the given language, then settinginnerText
to the translation:You can select the element by Specific Tag Value: