-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Obsolete / Previous Translations to Yecc Parser #30
Conversation
Pull Request Test Coverage Report for Build 79807df4fb6c61ff6e1b043f47faf828cd08fb68-PR-30Details
💛 - Coveralls |
f229cf8
to
e73df64
Compare
1212c27
to
09b0e66
Compare
@whatyouhide TokenizerI decided to handle it in the tokenizer because:
If I just did parsing manually after the yecc part, I would replicate a large part of what yecc does. Yecc IssuesNo matter how I try to adapt the One Attempt (only for obsolete)Nonterminals grammar translations translation pluralizations pluralization
strings comments maybe_msgctxt maybe_obsolete_msgctxt obsolete_strings
obsolete_pluralizations obsolete_pluralization.
Terminals str msgid msgid_plural msgctxt msgstr plural_form comment obsolete.
Rootsymbol grammar.
grammar ->
translations : '$1'.
% A series of translations. It can be just comments (which are discarded and can
% be empty anyways) or comments followed by a translation followed by other
% translations; in the latter case, comments are attached to the translation
% that follows them.
translations ->
comments : [{comments, '$1'}].
translations ->
comments translation translations : [add_comments_to_translation('$2', '$1')|'$3'].
% TODO: Parse previous / obsolete
translation ->
maybe_msgctxt msgid strings msgstr strings : {translation, #{
comments => [],
msgctxt => '$1',
msgid => '$3',
msgstr => '$5',
po_source_line => extract_line('$2')
}}.
translation ->
maybe_obsolete_msgctxt obsolete msgid obsolete_strings obsolete msgstr obsolete_strings : {translation, #{
comments => [],
msgctxt => '$1',
msgid => '$4',
msgstr => '$7',
po_source_line => extract_line('$3')
}}.
translation ->
maybe_msgctxt msgid strings msgid_plural strings pluralizations : {plural_translation, #{
comments => [],
msgctxt => '$1',
msgid => '$3',
msgid_plural => '$5',
msgstr => plural_forms_map_from_list('$6'),
po_source_line => extract_line('$2')
}}.
translation ->
maybe_obsolete_msgctxt obsolete msgid obsolete_strings obsolete msgid_plural obsolete_strings obsolete_pluralizations : {plural_translation, #{
comments => [],
msgctxt => '$1',
msgid => '$4',
msgid_plural => '$7',
msgstr => plural_forms_map_from_list('$8'),
po_source_line => extract_line('$3')
}}.
pluralizations ->
pluralization : ['$1'].
pluralizations ->
pluralization pluralizations : ['$1'|'$2'].
pluralization ->
msgstr plural_form strings : {'$2', '$3'}.
obsolete_pluralizations ->
obsolete_pluralization : ['$1'].
obsolete_pluralizations ->
obsolete_pluralization obsolete_pluralizations : ['$1'|'$2'].
obsolete_pluralization ->
obsolete msgstr plural_form obsolete_strings : {'$2', '$3'}.
strings ->
str : [extract_simple_token('$1')].
strings ->
str strings : [extract_simple_token('$1')|'$2'].
obsolete_strings ->
str : [extract_simple_token('$1')].
obsolete_strings ->
str obsolete strings : [extract_simple_token('$1')|'$2'].
comments ->
'$empty' : [].
comments ->
comment comments : [extract_simple_token('$1')|'$2'].
maybe_msgctxt ->
'$empty' : nil.
maybe_msgctxt ->
msgctxt strings : '$2'.
maybe_obsolete_msgctxt ->
'$empty' : nil.
maybe_obsolete_msgctxt ->
obsolete msgctxt strings : '$2'.
Erlang code.
extract_simple_token({_Token, _Line, Value}) ->
Value.
extract_line({_Token, Line}) ->
Line.
plural_forms_map_from_list(Pluralizations) ->
Tuples = lists:map(fun extract_plural_form/1, Pluralizations),
maps:from_list(Tuples).
extract_plural_form({{plural_form, _Line, PluralForm}, String}) ->
{PluralForm, String}.
add_comments_to_translation({TranslationType, Translation}, Comments) ->
{TranslationType, maps:put(comments, Comments, Translation)}. Error with that attempt: (The example here is one of a thousand. I tried rearanging things a lot of times with no better result.) |
e73df64
to
0be8c63
Compare
09b0e66
to
79807df
Compare
0be8c63
to
31f594f
Compare
79807df
to
fdfbf6d
Compare
@whatyouhide I've some free time on my hands in the next few days. I would appreciate it if you had the time to have a closer look so that I could make some progress on this. (Not trying to stress you, I just wanted you to know that I could use the time more efficiently if you had some time to spare for me.) I'll also start working on the gettext integration since there it shouldn't matter which parser is used. |
0e4234e
to
0e66700
Compare
fdfbf6d
to
115a814
Compare
0e66700
to
e6fce9f
Compare
115a814
to
80b94fb
Compare
e6fce9f
to
69dc502
Compare
80b94fb
to
8e81084
Compare
69dc502
to
4094388
Compare
ccf0e2c
to
9a21fc2
Compare
4094388
to
b9f141c
Compare
9a21fc2
to
3cb8812
Compare
b9f141c
to
7ea77e0
Compare
3cb8812
to
a09567d
Compare
a09567d
to
79c5e83
Compare
* Switch to Yecc Based Parser * Add Obsolete / Previous Translations to Yecc Parser (#30)
No description provided.