Skip to content

Add an "_" builtin to call into gettext#7036

Merged
faho merged 3 commits intofish-shell:masterfrom
faho:builtin-gettext
May 29, 2020
Merged

Add an "_" builtin to call into gettext#7036
faho merged 3 commits intofish-shell:masterfrom
faho:builtin-gettext

Conversation

@faho
Copy link
Member

@faho faho commented May 24, 2020

Description

We already have gettext in C++ (if available), so it seems weird to
fork off a command to start it from script.

This is only for fish's own translations. There's no way to call into
other catalogs, it just translates all arguments separately.

This is faster by a factor of ~1000, which allows us to call
translations much more, especially from scripts.

E.g. making fish_greeting global by default would hurt cost-wise,
given that my fish starts up in 8ms and just calling the current _
function takes 2ms, and that would have two calls.

Incidentally, this also makes us rely on a weirdly defined function
less, so it:
Fixes #6804.

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.md

We already have gettext in C++ (if available), so it seems weird to
fork off a command to start it from script.

This is only for fish's own translations. There's no way to call into
other catalogs, it just translates all arguments separately.

This is faster by a factor of ~1000, which allows us to call
translations much more, especially from scripts.

E.g. making fish_greeting global by default would hurt cost-wise,
given that my fish starts up in 8ms and just calling the current `_`
function takes 2ms, and that would have two calls.

Incidentally, this also makes us rely on a weirdly defined function
less, so it:
Fixes fish-shell#6804.
@faho faho added this to the fish 3.2.0 milestone May 24, 2020
Let's see if that filename works out.
Copy link
Member

@zanchey zanchey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I'd considered this in the past and decided against it, but I can't find any reason why; perhaps that was when fish handled changes in locale variables rather worse than it does now. So I think it's a good idea!

@faho faho merged commit 4785440 into fish-shell:master May 29, 2020
@faho
Copy link
Member Author

faho commented May 29, 2020

Merged.

@faho faho deleted the builtin-gettext branch May 29, 2020 18:53
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Git tab completion error when no gettext

2 participants