turquoiseowl / i18n

Smart internationalization for ASP.NET
Other
556 stars 156 forks source link

"i18n.PostBuild.exe": don't do ".backups" and time stamps #279

Closed artkpv closed 6 years ago

artkpv commented 8 years ago

Hello, Thanks for the great tool!

How can we stop i18n.PostBuild.exe to make the backup files and stop it to make time stamps in .po files like "POT-Creation-Date" and "PO-Revision-Date" ? This is a noise to git which handles updates and backups nicely.

turquoiseowl commented 8 years ago

AFAIK there aren't any switches currently to control that but please feel free to contribute that functionality. Thanks.

jeancroy commented 8 years ago

I may have an interest to fix this on our side too, I'll have one question.

The problem: PostBuild regenerate pot & po data with a timestamp that basically is the time of the last build. In a source control environment that timestamp conflict on each merge or almost. :-1:

I can exclude /locale/.pot and /locale/.backup from source control as they are automatically generated, but would like to keep the .po as it contain human generated translation.

The curlpit:

In this method SaveTranslation var POTDate = DateTime.Now;

So basically the metadata can never stay the same.

The patch:

I'm thinking of a flag that disable those two lines

The question

What exactly is MergeAllTranslation doing ?

In particular does it do the same as PoEdit > Catalog> UpdateFromPotFIle ? screenshot_1

If so it'll be worth 1000x time to do it manually and don't break source control.

The long term plan

Allow generated file to be indempotent. For example take the md5 of the pot file body (without timestamp header) and if body is the same, abort save template / mere translation.

My plan

Translation got pushed away on my current project, so I'll disable autobuild. But if this is still a problem in about a month I'll find time to correct it cleanly.

turquoiseowl commented 8 years ago

A nice feature of PO GetText is that translation messages that become redundant over time are preserved in the .PO files (as unreferenced messages) in case they are ever brought back into use. The logic that does this is what the 'Merge' refers to. Here's some relevant notes from the code:

        public void MergeTranslation(IDictionary<string, TemplateItem> src, Translation dst)
        {
        // Our purpose here is to merge newly parsed message items (src) with those already stored in a translation repo (dst).
        // 1. Where an orphan msgid is found (present in the dst but not the src) we update it in the dst to remove all references.
        // 2. Where a src msgid is missing from dst, we simply ADD it to dst.
        // 3. Where a src msgid is present in dst, we update the item in the dst to match the src (references, comments, etc.).
        //

I'm not sure whether that's the same as the PO edit feature, but also can't see we can avoid the merge as part of PostBuild.

vhatuncev commented 7 years ago

Any updates on this issue? Really anoyning each build to see changes in po and pot files.

turquoiseowl commented 7 years ago

I think this was fixed #331.

That is included in the latest pre-release nuget packages, the latest being 2.1.11-pre002.

vhatuncev commented 7 years ago

Ok, thank you!

artkpv commented 6 years ago

Fixed in #331 @turquoiseowl thanks !