bugGNU gettext - Bugs: bug #56774, support Rust programming language

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #56774: support Rust programming language

Submitter:  Bruno Haible <haible>
Submitted:  Sun 18 Aug 2019 07:38:25 PM UTC
Votes:  100  
 
Category:  Other Severity:  4 - Important
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Thu 31 Mar 2022 07:27:52 PM UTC, comment #4: 

Although I sent it a couple of months ago, to make sure that my work is not lost, I'm posting it in the bug tracker so it's attached to the proper bug.

These are patches that add Rust support to gettext. They were deemed too big to be posted in the mailing list so here's a link to them:

<https://gitlab.gnome.org/-/snippets/2934>

(file #53025, file #53026)

Kévin <zecakeh>
Sat 01 Jan 2022 11:51:53 AM UTC, comment #3: 

I would like to work on that feature.

I looked around the code a bit and basically we need "format-rust.c" for msgfmt and "x-rust.c" for xgettext, right?

Here are Rust i18n libraries compatible with gettext:

  • gettext: emulates gettext. It provides gettext, ngettext, pgettext and npgettext methods on a Catalog object with the same API as the corresponding gettext functions. It doesn't support Rust string formatting.
  • gettext-rs: uses gettext. It provides gettext, ngettext, pgettext, npgettext, dcgettext, dcngettext, dgettext, dngettext methods with the same API as the corresponding gettext functions. It provides macros with the same names and the macro invocation operator '!' that allow Rust string formatting while keeping a regular function API. It doesn't support all of Rust string format yet.
  • tr: uses either of the two previous libraries. It provides a single tr! macro that allows Rust string formatting but has its own API to support the same features as gettext, ngettext, pgettext, npgettext. It doesn't support all of Rust string format yet. It provides its own extractor called xtr.

An extractor using keywords for gettext functions names and macro names should work with the two first libraries. A parser for Rust string format should work with all three libraries.

GNOME Rust apps usually use the gettext-rs library.

Kévin <zecakeh>
Wed 29 Dec 2021 10:45:20 AM UTC, comment #2: 

For reference, the gettext-rs crate allows us to use xgettext to translate strings.

If we only use functions, POT generation works well with Rust, detecting it like the C language. We can apply Rust string formatting at runtime by creating other functions around gettext-rs, and use the keyword option to make xgettext detect those new functions.

However we lose compile-time string formatting validation. To solve that, we need to use macros whose name always ends with a !, which makes them incompatible with the keyword option.

Kévin <zecakeh>
Wed 29 Dec 2021 10:26:31 AM UTC, comment #1: 

Also note this discussion about supporting Rust in GNOME i18n.

https://gitlab.gnome.org/GNOME/fractal/-/issues/874

Claude Paroz <claudep>
Sun 18 Aug 2019 07:38:25 PM UTC, original submission:  

Many applications are being written in Rust, such as web browsers (Firefox) and terminal emulators (alacritty).
Gettext should support this language.

Bruno Haible <haible>
Project Administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by zecakeh (Posted a comment)
  • -email is unavailable- added by claudep (Posted a comment)
  • -email is unavailable- added by sophie (Voted in favor of this item)
  • -email is unavailable- added by haible (Submitted the item)
  •  

    There are 100 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

     

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-03-31 zecakeh Attached File- Added 0001-Add-support-for-Rust-format-strings.patch, #53025
        Attached File- Added 0002-xgettext-Add-Rust-support.patch, #53026
    2020-11-03 sophie Carbon-Copy- Added sophie

    Back to the top


    Powered by Savane 3.9