{"action":"created","issue":{"url":"https://api.github.com/repos/htacg/tidy-html5/issues/328","labels_url":"https://api.github.com/repos/htacg/tidy-html5/issues/328/labels{/name}","comments_url":"https://api.github.com/repos/htacg/tidy-html5/issues/328/comments","events_url":"https://api.github.com/repos/htacg/tidy-html5/issues/328/events","html_url":"https://github.com/htacg/tidy-html5/pull/328","id":119336971,"number":328,"title":"Localized strings","user":{"login":"balthisar","id":3053246,"avatar_url":"https://avatars.githubusercontent.com/u/3053246?v=3","gravatar_id":"","url":"https://api.github.com/users/balthisar","html_url":"https://github.com/balthisar","followers_url":"https://api.github.com/users/balthisar/followers","following_url":"https://api.github.com/users/balthisar/following{/other_user}","gists_url":"https://api.github.com/users/balthisar/gists{/gist_id}","starred_url":"https://api.github.com/users/balthisar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/balthisar/subscriptions","organizations_url":"https://api.github.com/users/balthisar/orgs","repos_url":"https://api.github.com/users/balthisar/repos","events_url":"https://api.github.com/users/balthisar/events{/privacy}","received_events_url":"https://api.github.com/users/balthisar/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/htacg/tidy-html5/labels/Feature","name":"Feature","color":"02e10c"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/htacg/tidy-html5/milestones/6","html_url":"https://github.com/htacg/tidy-html5/milestones/5.1","labels_url":"https://api.github.com/repos/htacg/tidy-html5/milestones/6/labels","id":1030807,"number":6,"title":"5.1","description":"Next release","creator":{"login":"geoffmcl","id":1333435,"avatar_url":"https://avatars.githubusercontent.com/u/1333435?v=3","gravatar_id":"","url":"https://api.github.com/users/geoffmcl","html_url":"https://github.com/geoffmcl","followers_url":"https://api.github.com/users/geoffmcl/followers","following_url":"https://api.github.com/users/geoffmcl/following{/other_user}","gists_url":"https://api.github.com/users/geoffmcl/gists{/gist_id}","starred_url":"https://api.github.com/users/geoffmcl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geoffmcl/subscriptions","organizations_url":"https://api.github.com/users/geoffmcl/orgs","repos_url":"https://api.github.com/users/geoffmcl/repos","events_url":"https://api.github.com/users/geoffmcl/events{/privacy}","received_events_url":"https://api.github.com/users/geoffmcl/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":69,"state":"open","created_at":"2015-03-20T11:30:55Z","updated_at":"2015-12-12T17:29:45Z","due_on":"2015-12-14T23:00:00Z","closed_at":null},"comments":16,"created_at":"2015-11-29T04:58:56Z","updated_at":"2016-01-04T19:04:10Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/htacg/tidy-html5/pulls/328","html_url":"https://github.com/htacg/tidy-html5/pull/328","diff_url":"https://github.com/htacg/tidy-html5/pull/328.diff","patch_url":"https://github.com/htacg/tidy-html5/pull/328.patch"},"body":"- Added a new means of retrieving Tidy strings with an eye toward localization.\r\n- Sample string is added to demonstrate functionality.\r\n- There may be some edge cases to adjust to later.\r\n\r\nDon't actually merge this, please!\r\n\r\nIn this \"preview\" I've written a substitute string retrieval system that can be used to localize Tidy. Currently the only output merged to the new system is the missing semicolon entity error, but I imagine all of the output can transitioned. I've also replaced a lot of the defines with an enum, and will probably do the same for some of the other sets, as well as add lookup keys for them (currently some of them are used as bit fields, so I can't use their values to look up strings).\r\n\r\nIn the long run localize.c probably becomes message.c (it looks like it may have been originally), and all strings are loaded from a common source.\r\n\r\nThe approach I took might seem a bit odd at first, and it sacrifices library size as languages are added for the simplicity of not having to curate separate language dylibs. String lookup speed should be nearly identical to current methods but could be optimized in the future (someone early this year added a lot of hashing functions to libtidy).\r\n\r\nAnyway, have a look.\r\n"},"comment":{"url":"https://api.github.com/repos/htacg/tidy-html5/issues/comments/168771929","html_url":"https://github.com/htacg/tidy-html5/pull/328#issuecomment-168771929","issue_url":"https://api.github.com/repos/htacg/tidy-html5/issues/328","id":168771929,"user":{"login":"gagern","id":190759,"avatar_url":"https://avatars.githubusercontent.com/u/190759?v=3","gravatar_id":"","url":"https://api.github.com/users/gagern","html_url":"https://github.com/gagern","followers_url":"https://api.github.com/users/gagern/followers","following_url":"https://api.github.com/users/gagern/following{/other_user}","gists_url":"https://api.github.com/users/gagern/gists{/gist_id}","starred_url":"https://api.github.com/users/gagern/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gagern/subscriptions","organizations_url":"https://api.github.com/users/gagern/orgs","repos_url":"https://api.github.com/users/gagern/repos","events_url":"https://api.github.com/users/gagern/events{/privacy}","received_events_url":"https://api.github.com/users/gagern/received_events","type":"User","site_admin":false},"created_at":"2016-01-04T19:04:10Z","updated_at":"2016-01-04T19:04:10Z","body":"> I *really* like the tools that are available for PO files, and I thank @gagern for really making the point stick that it's a format with wide support.\r\n\r\nI'm glad my comment turned out to be this useful.\r\n\r\n> One thing e.g. gettext handles that the current implementation with its simple lookup table would have problems with is [plural forms](https://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html#Plural-forms) from different languages. It is quite surprising how much these vary!\r\n\r\nOne possible approach to that is the following: for every string with a plural distinction, reserve a range of consecutive enum constants. E.g. `STRING_ERROR`, `STRING_ERROR_PLURAL1 = STRING_ERROR + 1` and so on. There doesn't seem to be a reasonably common language with more than 6 different plural forms, so `STRING_ERROR_PLURAL5 = STRING_ERROR + 5` could be the last. That way, you can build something that works essentially like [`ngettext`](https://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html#index-ngettext) in that it selects the appropriate plural form for the current language. In the PO file, the plural forms should of course be represented using [the appropriate PO format](https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html#index-plural-forms_002c-in-PO-files).\r\n\r\nYou might want to be specific up front whether you support [argument reordering](https://www.gnu.org/software/gettext/manual/html_node/c_002dformat.html) for printf-style format strings. Not doing so may force translators to choose clumsy formulations in order to stick to the english order of substitutions.\r\n\r\nI think you should make the `.pot` file (translation template) readily available to likely contributors, e.g. by committing them to git. You should also avoid absolute paths in there. I'm not yet decided whether it would be wise to add the [`c-format` flag](https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html#index-c_002dformat-flag) to strings containing `%` as part of the automatic conversion. Doing so might be a useful hint to translators, and may enable additional helpful features in some tools. Getting this wrong would be rather confusing, though, so you should only do this if you are sure the heuristics are correct."}}