59 lines
4.0 KiB
Plaintext
59 lines
4.0 KiB
Plaintext
I need a python program to scan for lexical strings in a set of files from a mojolicious application.
|
|
I use chevrons to enclose a meta symbol in the context of this spec.
|
|
|
|
Initially establish a parameter -p (panel)for the name of the Mojolicious panel (call it <panel>), no default, error if not supplied.
|
|
create second parameter -s (system) - call it <system>, default "SME11"
|
|
|
|
Establish logging.basicConfig.
|
|
|
|
Check <panel> is capitalised and that <system>/usr/share/smanager/lib/SrvMngr/Controller/<panel>.pm exists log error and exit otherwise.
|
|
|
|
Scan the file <system>/usr/share/smanager/lib/SrvMngr/Controller/<panel>.pm looking for my $title = $c->("<something>") or my $title = $c->('<something>') (ignore spaces).
|
|
<something> will be of the form <prefix>_<text>. <prefix> will be 2..4 alphas. Save and log the <prefix>. log Error and exit if not found.
|
|
|
|
Scanning:
|
|
<system>/usr/share/smanager/lib/SrvMngr/Controller/<panel>.pm
|
|
<system>/usr/share/smanager/themes/<default and AdminLTE>/templates/lowercase(<panel>).html.ep
|
|
<system>/usr/share/smanager/themes/<default and AdminLTE>/templates/partials/_<prefix>_<any text>.html.ep
|
|
|
|
Extract all strings of <prefix>_<some text> into a structure and save filename(s) in which it was found (may be more than one)
|
|
Deduplicate it.
|
|
|
|
Look in <system>/usr/share/smanager/lib/SrvMngr/I128N/<panel>/lowercase(<panel>)_en.lex for each of the <prefix>_<some text> found earlier and create a new file <system>/usr/share/smanager/lib/SrvMngr/I128N/<panel>/lowercase(<panel>)_en.lex.new of the corresponding lines from the .lex file that match.
|
|
|
|
For all <prefix>_<sometext> ones not found in the .lex file write them into the .new in the format '<prefix>_<sometext>' => '<sometext> with underlines mapped to spaces',
|
|
|
|
Log the number of lines in the .new file versus number of lines in the .lex file.
|
|
|
|
Read in from a JSON file (*Templates/languages.json) a list of country codes - example - {"language": "Bulgarian", "code": "bg"}
|
|
|
|
Scan <system>/usr/share/smanager/lib/SrvMngr/I128N/<panel>/lowercase(<panel>)_<language code> for all the <prefix>_<sometext> retained from above, creating the .new file from the ones found, and creating new lines:
|
|
'<prefix>_<sometext>' => '<sometext>', where <sometext> is taken from the _en.lex.new file.
|
|
|
|
As each language is done, log the number of lines in the .new file versus number of lines in the .lex file.
|
|
|
|
Rescan all
|
|
<system>/usr/share/smanager/lib/SrvMngr/Controller/<panel>.pm
|
|
<system>/usr/share/smanager/themes/<default and AdminLTE>/templates/lowercase(<panel>).html.ep
|
|
<system>/usr/share/smanager/themes/<default and AdminLTE>/templates/partials/_<prefix>_<any text>.html.ep
|
|
using the regex string pattern = r"l[\s|(][\'|\"](.*)[\'|\"]\)".
|
|
For each one found:
|
|
if it has <prefix>_ in front then discard it
|
|
Otherwise look in <system>/usr/share/smanager/lib/SrvMngr/I128N/general/general_en.lex
|
|
and if found it copy line from .lex across to <system>/usr/share/smanager/lib/SrvMngr/I128N/general/general_en.lex.new (which may already exist)
|
|
otherwise create a line in .new as follows: '<sometext>' =>'<sometext> with underline mapped to space.',
|
|
When finished, log line counts for the general .lex and .new file.
|
|
|
|
As before, Scan <system>/usr/share/smanager/lib/SrvMngr/I128N/general/general_<language code> for all the <prefix>_<sometext>, creating the .new file from the ones found in the retained ones above, and creating new lines:
|
|
'<prefix>_<sometext>' => '<sometext>', where <sometext> is taken from the _en.lex.new file.
|
|
|
|
As each language is done, log the number of lines in the .new file versus number of lines in the .lex file.
|
|
|
|
Scan the lex strings found structure, looking for ones with <prefix>_<just one word>. scan the general lex file (new one) for the <just one word>, and if not found, drop it in:
|
|
'<just one word>' => '<just one word>', and scan the general other language files for it, creating it if necessary.
|
|
edit the original file(s) in which that lexical string was found to map <prefix>_<just one word> to <just one word>
|
|
|
|
Log the number of lines per languge per general .lex and .new file.
|
|
|
|
|