Topic on Extension talk:HitCounters

Can I edit the output string to assign a start date?

16
Ulf Dunkel (talkcontribs)

I run a wiki for several years now and have installed HitCounters as of today. Now my MainPage shows the line

"This page has been accessed 8 times."

How can I adjust these strings and add a date, like e.g.

"This page has been accessed 8 times since 2021-03-22."

I didn't find any such string in /extensions/HitCounters/i18n/ or elsewhere in its extension folder.

WikiForMen (talkcontribs)

You can edit in HitCounters/i18n/en.json

"hitcounters-viewcount": "This page has been accessed $1 times.",

and change it into

   "hitcounters-viewcount": "This page has been accessed $1 times since 2021-03-22.",

--WikiForMen (talk) 20:10, 22 March 2021 (UTC)

Kghbln (talkcontribs)

I agree it should be "hitcounters-viewcount" rather than "viewcount" starting from MW 1.36+. I tried to create a patch.

WikiForMen (talkcontribs)

He is using MW 1.32.2. The key "hitcounters-viewcount" is missing in all i18n files of the HitCounters extension. --WikiForMen (talk) 00:57, 26 March 2021 (UTC)

Kghbln (talkcontribs)

The version of HitCounters is calling the "hitcounters-viewcount" key instead of "viewcount"?

WikiForMen (talkcontribs)

As a developer I use since years my own version of extension HitCounters, compatible with 1.25+ until 1.35+, there I passed "viewcount" from /languages/i18n/en.json into "hitcounters-viewcount" in /extensions/HitCounters/i18n/en.json as all HitCounters messages have the "hitcounters-keyname" structure. See here. I have no idea, why "viewcount" was left behind in the core.--WikiForMen (talk) 14:26, 26 March 2021 (UTC)

Ulf Dunkel (talkcontribs)

Thank you for this hint, but the mentioned string is not in my en.json file which I also re-checked from the current master. Mine reads as follows:

{
"@metadata": {
"authors": [
"Mark A. Hershberger"
]
},
"hitcounters-extensionname": "Hit Counters",
"hitcounters-desc": "Provides per page view statistics",
"hitcounters-page-label": "$1",
"hitcounters-nviews": "$1 views",
"popularpages": "Popular pages",
"popularpages-summary": "",
"hitcounters-pageinfo-views": "Number of views",
"hitcounters-statistics-header-views": "View statistics",
"hitcounters-statistics-views-total": "Views total",
"hitcounters-statistics-views-total-desc": "Views to non-existing pages and special pages are not included",
"hitcounters-statistics-views-peredit": "Views per edit",
"hitcounters-statistics-mostpopular": "Most viewed pages",
"abusefilter-edit-builder-vars-page-views": "Page views",
"abusefilter-edit-builder-vars-movedfrom-views": "Source page views",
"abusefilter-edit-builder-vars-movedto-views": "Target page views"
}

So I guess the string is stored somewhere else. Any further hints?

WikiForMen (talkcontribs)

If the mentioned string is not in the en.json file, so: insert it! ;-)

It is called in the file includesHitCounters.hooks.php on line 157

$skin->msg( 'viewcount' )

Note that the HitCounters extension was outsourced from the MediaWiki's core code and that you still have the string in question in the MediaWiki's file en.json. --WikiForMen (talk) 12:57, 23 March 2021 (UTC)

Ulf Dunkel (talkcontribs)

What I found now was this:

root@ubuntu:/var/www/vhosts/intactiwiki.org/w/pool# grep -r "has been accessed" *
languages/i18n/en-gb.json:      "viewcount": "This page has been accessed $1 times.",
languages/i18n/en.json: "viewcount": "This page has been accessed $1 times.",
languages/i18n/mni.json:        "viewcount": "This page has been accessed $1 times?",
tests/parser/preprocess/All_system_messages.expected:This page has been accessed $1 times.
tests/parser/preprocess/All_system_messages.txt:This page has been accessed $1 times.

No change in any of these files shows any effect on the actual page output.

WikiForMen (talkcontribs)

As I suspected, this string is still in those files, which are from an installation prior to REL 1.25. The creators of the extension apparently forgot to transfer these entries into the extension. You can transfer them and alter them at your choice. But use "hitcounters-viewcount" instead of "viewcount" as key.--WikiForMen (talk) 13:00, 23 March 2021 (UTC)

Ulf Dunkel (talkcontribs)

I now have added two lines to my /extensions/HitCounters/i18n/en.json file:

"hitcounters-viewcount": "This page has been accessed $1 times since 2021-03-22.",
"viewcount": "This page has been accessed $1 times since 2021-03-22."

No change in my Wiki page footers afterwards. In fact, this file is being read, because when I had a typo in it, my Wiki reported a large amount of error lines until I fixed it. But neither "hitcounters-viewcount" nor "viewcount" seem to be used from this file.

WikiForMen (talkcontribs)

A. I changed it on my website and it works. See the footer here!

B. Consider caching issues!

  1. Empty the table "l10n_cache" table in your data base.
  2. Run the "runJobs.php" maintenance script.

C. You say, you have added two lines to my /extensions/HitCounters/i18n/en.json file! "en"!!! But in your wikis is $wgLanguageCode = "de"! Also in the english speaking one!

You should one line to your /extensions/HitCounters/i18n/de.json file:

"hitcounters-viewcount": "Diese Seite wurde bisher {{PLURAL:$1|einmal|$1 mal}} abgerufen seit 22. März 2021.",

--WikiForMen (talk) 17:36, 24 March 2021 (UTC)

Ulf Dunkel (talkcontribs)

Thank you for your patience with me. Where can you see how the $wgLanguageCode for my wikis is set up? I run various language instances which share a CommonSettings.php file but have their own LocalSettings.php files. A grep search for $wgLanguageCode showed only $wgLanguageCode = "en" for my English wiki. Where do I have to check this?

I tried to empty the table "l10n_cache" for my English wiki but got an empty result in phpmyadmin. What am I doing wrong?

I also added the suggested German string to /extensions/HitCounters/i18n/de.json without any change.

Even after I copied the table structure into a new table i10n_cache_backup, deleted i10n_cache, renamed (the empty) i10n_cache_backup to i10n_cache and ran php runJobs.php, there's no change in my footer output. Weird.

Any help is really appreciated.

WikiForMen (talkcontribs)

Strange! I found also in mediawiki-1.35.1/languages/i18n/de.json this:

"viewcount": "Diese Seite wurde bisher {{PLURAL:$1|einmal|$1 mal}} abgerufen.",

I was sure, that this was removed from the core.

Normally you may set $wgLanguageCode = "de"; for subdomain de.intactiwiki.org and $wgLanguageCode = "es"; for subdomain es.intactiwiki.org, respectively in the corresponding localsettings.php file.

I see on your site in de.intactiwiki.org, en.intactiwiki.org, and es.intactiwiki.org the sidebar, the tabs, and the footer in German language. So I guess that in all your localsettings.php files the variable $wgLanguageCode is set to "de". OK, I see you are using Extension:UniversalLanguageSelector.

I have no glue, what you are doing wrong. :-( You are sure to have upload de.json and en.json into the right folder?

I changed /extensions/HitCounters/i18n/en.json to this:

"hitcounters-viewcount": "This page has been accessed {{PLURAL:$1|once|$1 times}} since 2021-01-01.",

upload it with FTP, and it worked immediately (and without emptying the table "l10n_cache") on "en.wikimannia.org" as you can see yourself. --WikiForMen (talk) 00:39, 26 March 2021 (UTC)

Ulf Dunkel (talkcontribs)

I finally figured out what was going on:

  • I run MediaWiki 1.32.2 and the relevant HitCounters extension 0.3 (7638419).
  • HitCounters 0.3 uses the global "viewcount" key which should be available from /wiki/languages/i18n/'<language>.json.
  • Adding the "viewcount" key or "hitcounters-viewcount" to /extensions/HitCounters/i18n/<language>.json didn't have any effect in Hitcounters 0.3.
  • Because I run multiple language instances of a wiki which share most files from a shared pool, I tried and edited the relevant strings in /wiki/languages/i18n/<language>.json. BUT - I had overseen that all localized wiki instances still had their own /languages/ folders.
  • So I removed them and added symbolic links to /wiki/pool/languages/ in order to have all wiki instances use one shared folder.


Now everything works fine for me. I guess I have to adjust things once more when I update MediaWiki to 1.35 or higher. I stored the enhanced files for me like this:

da.json: "viewcount": "Siden er vist $1 gange siden 22. marts 2021.",

de:json: "viewcount": "Diese Seite wurde seit dem 22.03.2021 bisher $1 mal abgerufen.",

en.json: "viewcount": "This page has been accessed $1 times since 22 March 2021.",

es.json: "viewcount": "Esta página ha recibido $1 visitas desde el 22 de marzo de 2021.",

fi.json: "viewcount": "Tämä sivu on näytetty $1 kertaa 22. maaliskuuta 2021 lähtien.",

fr.json: "viewcount": "Cette page n’a jamais été consultée depuis le 22 mars 2021.",

is.json: "viewcount": "Þessi síða hefur verið skoðuð $1 sinnum síðan 22. mars 2021.",

nl.json: "viewcount": "Deze pagina is $1 keer bekeken sinds 22 maart 2021.",

sv:json: "viewcount": "Den här sidan har visats $1 gånger sedan 22 mars 2021.",

sw.json: "viewcount": "Ukurasa huu umetembelewa mara $1 tangu Machi 22, 2021.",

tr.json: "viewcount": "Bu sayfaya 22 Mart 2021 tarihinden $1 defa erişilmiş.",


As I am not familiar with Arabic, Farsi, Hebrew and find editing rtl texts in Ubuntu's nano editor rather difficult, I left those three languages for my wiki instances untouched so far.

WikiForMen (talkcontribs)
"BUT - I had overseen that all localized wiki instances still had their own /languages/ folders."

I was afraid about something like this! ;-) --WikiForMen (talk) 13:42, 26 March 2021 (UTC)