Bug 160409 - Make copyright year string a variable
Summary: Make copyright year string a variable
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Linguistic (show other bugs)
Version:
(earliest affected)
24.8.0.0 alpha0+ Master
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: difficultyBeginner, easyHack, skillCpp, topicCleanup
Depends on:
Blocks:
 
Reported: 2024-03-28 14:53 UTC by Xisco Faulí
Modified: 2024-04-21 18:07 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Xisco Faulí 2024-03-28 14:53:40 UTC
In many places throughout the code there is a string with the copyright year.
These strings have to be changed once every year. See https://gerrit.libreoffice.org/c/core/+/164794

Some info from https://gerrit.libreoffice.org/c/core/+/164748/comments/f928734c_0cc66a4d
"as suggested earlier for the few strings where it is relevant for translations (cui and sfx2) to indeed use the variable mechanism - dialogs using the strings already do replacement for PRODUCTNAME or similar, so adding one more for copyright year should be pretty straightforward.

The other files can also be handled with variables of course just to streamline the process of bumping the version, but those are less critical/won't affect translators."
Comment 1 Stéphane Guillou (stragu) 2024-03-28 15:05:56 UTC
Thanks Xisco, confirmed as discussed in ESC.
Comment 2 Edward 2024-04-21 13:17:04 UTC
I would like to pick up this issue/bug as a newbie to LibreOffice dev. I am seeing that a VER_YEARRANGE accomplishes the desired task and is already defined in include/version.hrc. It would make sense to me to re-use that existing definition, however....

VER_YEARRANGE is suffixed with the text "by" and not all Copyright statements use this text. I am reading "...relevant for translations..." in the issue/bug description, so I suspect that it would be best to define something without "by" and then use that for for the definition of VER_YEARRANGE. This then begs the question of where it should be defined so that it can be used throughout the application.

Although I understand that LibreOffice is multi-lingual, I am not seeing the text "2024" in anything I would consider a translation file. Is the copyright text actually translated?

As well, I am finding 5 instances in HTML files that would benefit from the standardization of a variable for the copyright statement, but there are many other instances in TXT files and I am unaware of any mechanism to implement such a variable in a TXT files. Is this possible / desirable?

I would much appreciate guidance from more folks more experienced with this application in regards to where the new definition should be so that it can be used universally.
Comment 3 Buovjaga 2024-04-21 15:41:24 UTC
Edward: you could do a change like this:

diff --git a/configure.ac b/configure.ac
index 4bb5ad4d97da..6a110f62c6ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -520,8 +520,9 @@ AC_DEFINE_UNQUOTED(LIBO_VERSION_MICRO,$LIBO_VERSION_MICRO)
 AC_DEFINE_UNQUOTED(LIBO_VERSION_PATCH,$LIBO_VERSION_PATCH)
 
 git_date=`git log -1 --pretty=format:"%cd" --date=format:'%Y' 2>&/dev/null`
-LIBO_THIS_YEAR=${git_date:-2024}
+LIBO_THIS_YEAR=${git_date:-2025}
 AC_DEFINE_UNQUOTED(LIBO_THIS_YEAR,$LIBO_THIS_YEAR)
+AC_SUBST(LIBO_THIS_YEAR)
 
 dnl ===================================================================
 dnl Product version

and then changes to relevant .mk files like

diff --git a/postprocess/CustomTarget_registry.mk b/postprocess/CustomTarget_registry.mk
index 8a503e39862a..6c16df58ddd9 100644
--- a/postprocess/CustomTarget_registry.mk
+++ b/postprocess/CustomTarget_registry.mk
@@ -572,6 +572,7 @@ postprocess_main_SED := \
        -e 's,$${ABOUTBOXPRODUCTVERSION},$(LIBO_VERSION_MAJOR).$(LIBO_VERSION_MINOR).$(LIBO_VERSION_MICRO).$(LIBO_VERSION_PATCH)$(LIBO_VERSION_SUFFIX),g' \
        -e 's,$${ABOUTBOXPRODUCTVERSIONSUFFIX},$(LIBO_VERSION_SUFFIX_SUFFIX),g' \
        -e 's,$${OOOVENDOR},$(if $(OOO_VENDOR),$(subst $(COMMA),\x2c,$(OOO_VENDOR)),The Document Foundation),g' \
+       -e 's,$${LIBO_THIS_YEAR},$(LIBO_THIS_YEAR),g' \
        -e 's,$${PRODUCTNAME},$(PRODUCTNAME),g' \
        -e 's,$${PRODUCTVERSION},$(PRODUCTVERSION),g' \
        -e 's,$${PRODUCTEXTENSION},.$(LIBO_VERSION_MICRO).$(LIBO_VERSION_PATCH)$(LIBO_VERSION_SUFFIX),g' \
diff --git a/readlicense_oo/CustomTarget_readme.mk b/readlicense_oo/CustomTarget_readme.mk
index bb3b41e768a8..c4ac26073d57 100644
--- a/readlicense_oo/CustomTarget_readme.mk
+++ b/readlicense_oo/CustomTarget_readme.mk
@@ -44,6 +44,7 @@ $(readlicense_oo_DIR)/readme.xrm : \
 endif
 
 readlicense_oo_README_SED := \
+       -e 's,$${LIBO_THIS_YEAR},$(LIBO_THIS_YEAR),g' \
        -e 's,$${PRODUCTNAME},$(PRODUCTNAME),g' \
        -e 's,$${PRODUCTVERSION},$(LIBO_VERSION_MAJOR).$(LIBO_VERSION_MINOR),g' \

But then there is also ReplaceStringHookProc function in desktop/source/app/app.cxx which is getting product name and version etc. via utl::ConfigManager and build id via utl::Bootstrap to populate About dialog text. I'm not sure what would be the best approach for this, but I hope you can consider it.
Comment 4 Buovjaga 2024-04-21 15:44:24 UTC
Note that compilerplugins/LICENSE.TXT seen in https://gerrit.libreoffice.org/c/core/+/164794 is part of the source and will need to be manually changed in the future as well.
Comment 5 Edward 2024-04-21 18:07:43 UTC
Thanks Buovjaga. I will take that approach and let you know if I have additional questions / issues.