wichert / lingua

Translation toolkit for Python
Other
45 stars 32 forks source link

Updating existing .pot files #67

Closed techtonik closed 8 years ago

techtonik commented 8 years ago

Can lingua detect that existing .pot file does not need to be changed and don't write it?

wichert commented 8 years ago

Theoretically it could. What is your use case for wanting that?

techtonik commented 8 years ago

Working on Spinx based documentation translations. Currently Sphinx overwrites .pot files while regenerating and this includes new timestamps that give false alarms that translation sources changed.

piotr-dobrogost commented 8 years ago

I think this would need to be optional as updating .pot file updates date of extraction and I think this is good to have.

techtonik commented 8 years ago

@piotr-dobrogost date of extraction is good, but it should be updated only when there are changes in extracted strings.

techtonik commented 8 years ago

:+1:

piotr-dobrogost commented 8 years ago

@techtonik

date of extraction is good, but it should be updated only when there are changes in extracted strings.

I wouldn't say it's so simple. I find it useful to be able to look in the repo's history and see that extraction was done (seeing changed date inside pot file) in the process of preparing given release of project.

techtonik commented 8 years ago

@piotr-dobrogost that looks like a hack to me. Why don't your scripts set that date explicitly if you need this info?

piotr-dobrogost commented 8 years ago

@techtonik The whole point is to get this date changed only as a result of extraction so that you know extraction took place at this given date. After this "fix", when you look at .pot file with some date in the past you don't know if it's because someone forgot to extract texts or because nothing has changed.

techtonik commented 8 years ago

@piotr-dobrogost and for me the whole point is to let humans know that content is different from that is already translated, so they need to update the translation. How do you propose to do this otherwise?

wichert commented 8 years ago

I can see both options being useful. I was already planning on adding a command-line option to make this behaviour optional. The only thing I was not completely sure about was the direction: should I 1) make the new behaviour the default and add a --force-update flag to restore the old behaviour, or 2) should the old behaviour be the default and add an --update-on-change-only option.

piotr-dobrogost commented 8 years ago

I suppose it would make sense for default to be in line with behavior of other well known tools like gettext utilities.

wichert commented 8 years ago

@piotr-dobrogost That would apply if other tools had the same capability. Since they don't there is no way for lingua to copy existing behaviour here.

piotr-dobrogost commented 8 years ago

You mean there was no way to extract texts and update .pot files before lingua? :) I think most Python projects used babel for this, no?

techtonik commented 8 years ago

The default behavior is the thing that can make lingua different from packages that could not implement this functionality. I would vote for smart behaviour to be default and adding some --force option to regenerate file with timestamp anyway.