Script for updating Project-Id-Version ?

Asked by Mustufa Rangwala (Open ERP)

Hello,

Is there any way to directly update all pot+po file's Project-Id-Version, here i have to go to each file update its version if its change :(

Any command ?

Thank you,
mra

Question information

Language:
English Edit question
Status:
Solved
For:
Launchpad itself Edit question
Assignee:
No assignee Edit question
Solved by:
Mustufa Rangwala (Open ERP)
Solved:
Last query:
Last reply:
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) said :
#1

anyone can help me ?

Revision history for this message
Jeroen T. Vermeulen (jtv) said :
#2

The hard part there is fitting in with your process: knowing exactly what the right string is and when to update it. Frankly I have no experience with this field myself, but these may not be things we could decide for you.

For the annoying work of actually changing the files, do you know "sed"? Comes as standard on any Unix-like system I know of. It's like an editor, but scriptable instead of interactive.

A shell script like this would change your files (assuming, to keep it simple, that you don't have backslashes inside your version string). You could save that as replace-project-version-id somewhere where you can find it:

#! /bin/sh
# Replace Project-Id-Version string in a PO or POT file with the given new string.
# Usage: replace-project-version-id <new-project-version-id> <input-file> [<input-file> ...]

NEW_VERSION = "$1"
shift
FILES = "$2"

for FILE in $FILES
do
    sed -e "s/^\([Pp]roject-[Ii]d-[Vv]ersion:\) *[^\\]*/\1 $NEW_VERSION/" "$FILE" >"$FILE.new"
    mv -b -- "$FILE.new" "$FILE"
done

Now you can run this on e.g. all POT files in the current directory tree to replace all Project-Id-Version strings with "new-9.9-release":

find -name \*.pot | xargs replace-project-version-id "new-9.9-release"

(It would be similar for the PO files, though the gettext tools may have a more institutional way to propagate the change from the templates to PO files)

Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) said :
#3

Hello Jeroen T. Vermeulen ,

Thanks for your answer i got your point. It is good to use above script :)

Thank you,
Mustufa

Revision history for this message
David Planella (dpm) said :
#4

El dj 19 de 08 de 2010 a les 09:53 +0000, en/na mra (Open ERP) va
escriure:
> New question #121821 on Launchpad Translations:
> https://answers.edge.launchpad.net/rosetta/+question/121821
>
> Hello,
>
> Is there any way to directly update all pot+po file's Project-Id-Version, here i have to go to each file update its version if its change :(
>
> Any command ?
>

I'm not sure what build system your project uses, but generally this can
be updated easily by a build system variable. In projects using
autotools, if I'm not mistaken, it should be PACKAGE_VERSION in the
configure.ac file.

In any case, this needs to be only updated on the POT file. The gettext
tools used when updating translations to the newest POT template (e.g.
before a release) should take care of updating this field on the PO
files from the POT field.

Revision history for this message
Jeroen T. Vermeulen (jtv) said :
#5

David, thanks for clarifying that! I don't think Launchpad currently updates this in the PO files.

Revision history for this message
JoesCat (digital-y) said :
#6

Hi All,
I too was searching for an nswer and saw Jeroen's answer above.
I like that and modified it to put inside a Makefile.am for FontForge, located here:
https://github.com/JoesCat/fontforge/commit/b5e216087907289fb0b9c06ce87ef222ca910222
Hopefully, it get's pulled into mainline source code some time soon in the future, or modified further to be included as part of maintainer type code.

Looking at the second question, to convert all *.po files, you would probably want to modify the loop parameters to check for *.po