turquoiseowl / i18n

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

*.po files rebuild problem #325

Closed rafal-grycuk closed 7 years ago

rafal-grycuk commented 7 years ago

Hi, I have the following problem: On the beginning forgot to add the obj folder to the black list, thus the .pot and po files generates keys for files in that folder. When i added the folder to the black list and rebuild, the .pot file rebuild correctly, but unfortunatly the .po files contains path to not existed folders. Even the folder (obj) removal not resolve the issue. In addition, when i remove those files (.po) i regenerate them again everything is ok. This is not solution i seek, because i have translations in that files.

POT (correctly rebuild)

#: Views\Account\ChangePassword.cshtml:36
msgid "- be at least 8 characters long"
msgstr ""

#: Views\Account\ChangePassword.cshtml:37
msgid "- have at least one digit ('0'-'9')"
msgstr ""

#: Views\Account\ChangePassword.cshtml:38
msgid "- have at least one that is not letter or digit character "
msgstr ""

#: Views\Account\ChangePassword.cshtml:39
msgid "- have at least one uppercase ('A'-'Z')"
msgstr ""

#: Scripts\CustomScripts\FXSpotFwd.js:367
msgid "Accepted"
msgstr ""

#: ..\FXTrade.ViewModels\VM\FXOrderViewModels\FXOrderActiveOrdersFormViewModel.cs:32
#: ..\FXTrade.ViewModels\VM\FXOrderViewModels\FXOrderActiveOrdersFormViewModel.cs:35
#: ..\FXTrade.ViewModels\VM\FXSpotFwdViewModels\FXSpotFwdFormViewModel.cs:31
#: ..\FXTrade.ViewModels\VM\FXSpotFwdViewModels\FXSpotFwdFormViewModel.cs:34
#: Scripts\CustomScripts\FXTrade.js:8
msgid "Account"
msgstr ""

hu,po (not correctly rebuild)

# Scripts\CustomScripts\FXTrade.js:72
# obj\CIB UAT\AspnetCompileMerge\Source\Scripts\CustomScripts\FXTrade.js:80
# obj\CIB UAT\AspnetCompileMerge\TempBuildDir\Scripts\CustomScripts\FXTrade.js:80
# obj\CIB UAT\Package\PackageTmp\Scripts\CustomScripts\FXTrade.js:80
# obj\Synnetra UAT\AspnetCompileMerge\Source\Scripts\CustomScripts\FXTrade.js:80
# obj\Synnetra UAT\AspnetCompileMerge\TempBuildDir\Scripts\CustomScripts\FXTrade.js:80
# obj\Synnetra UAT\Package\PackageTmp\Scripts\CustomScripts\FXTrade.js:80
# obj\CIB UAT\AspnetCompileMerge\Source\Scripts\CustomScripts\FXTrade.js:72
# obj\CIB UAT\AspnetCompileMerge\TempBuildDir\Scripts\CustomScripts\FXTrade.js:72
# obj\CIB UAT\Package\PackageTmp\Scripts\CustomScripts\FXTrade.js:72
# Scripts\CustomScripts\FXTrade.js:79
#: Scripts\CustomScripts\FXTrade.js:79
#, Scripts\CustomScripts\FXTrade.js:72
#, obj\CIB UAT\AspnetCompileMerge\Source\Scripts\CustomScripts\FXTrade.js:80
#, obj\CIB UAT\AspnetCompileMerge\TempBuildDir\Scripts\CustomScripts\FXTrade.js:80
#, obj\CIB UAT\Package\PackageTmp\Scripts\CustomScripts\FXTrade.js:80
#, obj\Synnetra UAT\AspnetCompileMerge\Source\Scripts\CustomScripts\FXTrade.js:80
#, obj\Synnetra UAT\AspnetCompileMerge\TempBuildDir\Scripts\CustomScripts\FXTrade.js:80
#, obj\Synnetra UAT\Package\PackageTmp\Scripts\CustomScripts\FXTrade.js:80
#, obj\CIB UAT\AspnetCompileMerge\Source\Scripts\CustomScripts\FXTrade.js:72
#, obj\CIB UAT\AspnetCompileMerge\TempBuildDir\Scripts\CustomScripts\FXTrade.js:72
#, obj\CIB UAT\Package\PackageTmp\Scripts\CustomScripts\FXTrade.js:72
#, Scripts\CustomScripts\FXTrade.js:79
msgid "At least one amount need to be set."
msgstr "Az összeg mezot ki kell tölteni!"

I would like to remove those paths(lines) that starts with ", obj\" or " obj\"

turquoiseowl commented 7 years ago

We don't provide a way to remove those references, not that I can think of anyway. Sorry.

Can you not restore those PO files to their pre-merge state, from backup/git/source control?

turquoiseowl commented 7 years ago

Please note that v2.1.10 has just been released which fixes a bug with PostBuild introduced in v2.1.9.

turquoiseowl commented 7 years ago

Thinking about this some more, there's a new setting i18n.DisableReferences which may help.

You could try setting this to true then run PostBuild. Hopefully that will remove all references. Then set back to false and re-run PostBuild to just output the active references.

rafal-grycuk commented 7 years ago

Thank you for quick reply. I have installed the newest version and followed your steps with Disable references. Unfortunately it won't work completely. The *.po file is smaller (17MB -> 420KB) but references are still present :(


msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2016-12-06 14:13+01:00\n"
"PO-Revision-Date: 2016-12-06 14:13+01:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: i18n.POTGenerator\n"

# Views\Account\ChangePassword.cshtml:36
# obj\CIB UAT\AspnetCompileMerge\Source\Views\Account\ChangePassword.cshtml:36
# obj\CIB UAT\AspnetCompileMerge\TempBuildDir\Views\Account\ChangePassword.cshtml:36
# obj\CIB UAT\Package\PackageTmp\Views\Account\ChangePassword.cshtml:36
# obj\Synnetra UAT\AspnetCompileMerge\Source\Views\Account\ChangePassword.cshtml:36
# obj\Synnetra UAT\AspnetCompileMerge\TempBuildDir\Views\Account\ChangePassword.cshtml:36
# obj\Synnetra UAT\Package\PackageTmp\Views\Account\ChangePassword.cshtml:36
#: Views\Account\ChangePassword.cshtml:36
#, Views\Account\ChangePassword.cshtml:36
#, obj\CIB UAT\AspnetCompileMerge\Source\Views\Account\ChangePassword.cshtml:36
#, obj\CIB UAT\AspnetCompileMerge\TempBuildDir\Views\Account\ChangePassword.cshtml:36
#, obj\CIB UAT\Package\PackageTmp\Views\Account\ChangePassword.cshtml:36
#, obj\Synnetra UAT\AspnetCompileMerge\Source\Views\Account\ChangePassword.cshtml:36
#, obj\Synnetra UAT\AspnetCompileMerge\TempBuildDir\Views\Account\ChangePassword.cshtml:36
#, obj\Synnetra UAT\Package\PackageTmp\Views\Account\ChangePassword.cshtml:36
msgid "- be at least 8 characters long"
msgstr "```

Any other ideas ? 

PS: I have the pre-merge version of those files (git), but i will use them if there is no another option left (some translation will be lost).
PS2: IMHO i seems reasonable to add web config option to disable the timestamp in pot and po files, because they will be not tracked by git when there is no modifications made . e.g.
"POT-Creation-Date: 2016-12-06 14:13+01:00\n"
"PO-Revision-Date: 2016-12-06 14:13+01:00\n"
turquoiseowl commented 7 years ago

The content you are pasting is coming through all large, probably some markdown markup thing. Can you try pasting as a code block (three little apostrophe chars).

rafal-grycuk commented 7 years ago

Sorry for that. Fixed :)

turquoiseowl commented 7 years ago

It looks like you've been stung by the PostBuild bug introduced in 2.1.9. The symptom of that bug is/was reference entries (#:) being duplicated as flag entries (#,) and translator-comment entries (# ).

Note that you have the single reference entry (#:) which is presumably correct.

Apologies about that. All I can suggest, in lieu of a backup, is you do some regex search/replace to remove those lines starting with # obj and #, obj.

rafal-grycuk commented 7 years ago

I followed your advice and filter out the those references by writing a simple console app. The po file shrink to 28 KB :) Issue solved. Thank you for your help.

PS: What do think about this feature (disabling timestamp) i mention above ?

PS2: If anyone have similar problem, it can freely use my code to resolve this nuisance.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LinesRemover
{
    class Program
    {
        static void Main(string[] args)
        {
            string pathToFile = AppDomain.CurrentDomain.BaseDirectory + @"\en-GB\messages.po";
            List<string> lines = File.ReadAllLines(pathToFile).ToList();
            lines.RemoveAll(line => line.StartsWith("#, obj") || line.StartsWith("# obj")|| line.StartsWith("# ") || line.StartsWith("#,"));
            string outputPath = AppDomain.CurrentDomain.BaseDirectory + @"\Result\en-GB\messages.po";
            File.WriteAllLines(outputPath, lines);
            Console.WriteLine("DONE");
            Console.ReadKey();
        }
    }
}
turquoiseowl commented 7 years ago

Good to hear your problem is solved.

WRT timestamp, you are right and it is not implemented correctly at the moment as both POT-Creation-Date and PO-Revision-Date are simply re-written when as you say sometimes neither should be updated and sometimes only one should be updated.

I'm not able to spare the time to fix this myself at the moment. May I suggest you open a new issue and I'll mark it as Enhancement. And even better submit a Pull Request with the fix!

rafal-grycuk commented 7 years ago

Ok. Thx. I will do it.