diff mbox series

[RFC,3/5] git-sh-i18n: work with external scripts

Message ID 20190826235226.15386-4-newren@gmail.com (mailing list archive)
State New, archived
Headers show
Series Remove git-filter-branch from git.git; host it elsewhere | expand

Commit Message

Elijah Newren Aug. 26, 2019, 11:52 p.m. UTC
Scripts external to git could source $(git --exec-path)/git-sh-setup (as
we document in Documentation/git-sh-setup.txt).  This will in turn
source git-sh-i18n, which will setup some handy internationalization
infrastructure.  However, git-sh-i18n hardcodes the TEXTDOMAIN, meaning
that anyone using this infrastructure will only get translations that
are shipped with git.  Allow the external scripts to specify their own
translation domain but otherwise use our infrastructure for accessing
translations.

My original plan was to have git-filter-branch be the first testcase
using this feature, with a goal of minimizing the number of changes that
needed to be made to it when I moved it out of git.git.  However, I
realized after creating this patch that no strings in git-filter-branch
are translated.  However, the generalization could be useful if we move
other tools from git.git to an external location.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 git-sh-i18n.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Derrick Stolee Aug. 27, 2019, 1:28 a.m. UTC | #1
On 8/26/2019 7:52 PM, Elijah Newren wrote:
> Scripts external to git could source $(git --exec-path)/git-sh-setup (as
> we document in Documentation/git-sh-setup.txt).  This will in turn
> source git-sh-i18n, which will setup some handy internationalization
> infrastructure.  However, git-sh-i18n hardcodes the TEXTDOMAIN, meaning
> that anyone using this infrastructure will only get translations that
> are shipped with git.  Allow the external scripts to specify their own
> translation domain but otherwise use our infrastructure for accessing
> translations.
> 
> My original plan was to have git-filter-branch be the first testcase
> using this feature, with a goal of minimizing the number of changes that
> needed to be made to it when I moved it out of git.git.  However, I
> realized after creating this patch that no strings in git-filter-branch
> are translated.  However, the generalization could be useful if we move
> other tools from git.git to an external location.

Hm. Maybe extract it from this series for the YAGNI principle?

A noble goal, but in my opinion I'd prefer to see this be exercised
by something immediately.

Thanks,
-Stolee
diff mbox series

Patch

diff --git a/git-sh-i18n.sh b/git-sh-i18n.sh
index 8eef60b43f..3d04d5d515 100644
--- a/git-sh-i18n.sh
+++ b/git-sh-i18n.sh
@@ -5,7 +5,12 @@ 
 #
 
 # Export the TEXTDOMAIN* data that we need for Git
-TEXTDOMAIN=git
+if test -z "$TEXTDOMAIN_OVERRIDE"
+then
+	TEXTDOMAIN=git
+else
+	TEXTDOMAIN="$TEXTDOMAIN_OVERRIDE"
+fi
 export TEXTDOMAIN
 if test -z "$GIT_TEXTDOMAINDIR"
 then