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

Let a type rename words "Website", "Site", "Websites" and "Sites" #7833

Open
tsteur opened this issue May 4, 2015 · 0 comments
Open

Let a type rename words "Website", "Site", "Websites" and "Sites" #7833

tsteur opened this issue May 4, 2015 · 0 comments
Labels
c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.

Comments

@tsteur
Copy link
Member

tsteur commented May 4, 2015

A "type" could be a plugin that defines a type "Website" or "MobileApp". For example while a type "Website" may use the wording "Website and Websites" another type "MobileApp" may want to use the wording "Mobile App and Mobile Apps".

This will be needed for #7131, #4734 and #7826

Ideally, we would not use words like "Website", "Site", "Websites", "Sites" in translations but instead placeholders like %s (formatted strings via eg sprintf) whenever we want to use any website related term.

By default we should use a generic wording eg "Property and Properties" (see #7826). A plugin defining the type "Website" would rename those generic words to "Website and Websites". This will help us to avoid to have different wordings like "Website and Site". Sometimes, it would maybe make sense to use a generic term in general and not use %s at all. Eg instead of "No websites found" we could use "No matches found".

Does anyone have an idea how to achieve this? Such translations are composed pretty much everywhere and I doubt that we always have an $idSite (the type depends on the idSite). We would kinda need something like a static "::getCurrentType()" that is aware in which context we are and returns the correct type. So basically something like Piwik::translate('MyKey', getCurrentType()->getName()). If we handle multiple siteIds we need to use the generic wording. Meaning getCurrentType() would not return a specific type like "Website" or "MobileApp" but the "Generic" type.

Maybe we could use in translations something like ::property:: and ::properties:: that will be replaced at some point with "Website/Property" and "Websites/Properties"? Would this help somehow? But again at some point we need to replace this term and then we need to know which type we are currently handling. Doing it only in the Metadata API will most likely not work. I think we used such placeholders like this already somewhere but don't remember where. Does anyone?

To be considered

  • We do have to take care of lower/upper case. Eg we have "Website" and "website". In some languages it would be still "Website" and "Website". Eg in German many more words use a capital letter than in English. When using %s we would never know whether a lower or upper case version should be applied since it depends on the language. Here those placeholders could be interesting as a translator could eg use ::property:: or ::Property::.
  • We have similar problem for metrics. Eg the metric nb_visits is used in the report name Visits by days since last visit. Ideally a type would not have to rename all report names that contain the word "Visits" or "Visit" but only the actual words / metric "Visit" and "Visits" once.
  • We do have this event getClientSideTranslationKeys which allows plugin classes to make translations available client side. If someone uses eg hard coded $translations[]= 'General_Website', then we have a problem again. I don't think it is a big problem but we have to take care of such uses.

Another possible solution would be to just rename a translated term. Eg when current language is German ("Website" (en) => "Webseite" (de)) we would translate all words like "Website" and "Websites" into German to find out which words need to be replaced. Eg str_replace(Piwik::translate('Website'), getCurrentType()->getName(), 'My translated string'). One problem again would be whether to use ucfirst / lcfirst. Using placeholders would be better I think. This is rather a hacky solution.

Referencing @sgiehl as it is related to translations.

@tsteur tsteur added Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. labels May 4, 2015
@mattab mattab added this to the Short term milestone Jul 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

No branches or pull requests

2 participants