Skip to content

Commit

Permalink
Fix tests for WAGettextExporter to adaptations done in commit ef074d9
Browse files Browse the repository at this point in the history
…and added interface to create an exporter on a RBBrowserEnvironment
  • Loading branch information
jbrichau committed Jul 17, 2023
1 parent ef074d9 commit 74708e1
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
instance creation
newForRBEnvironment: aRBEnvironment
^ self new rbEnvironment: aRBEnvironment
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
exporting
exportCatalog
"WAGetTextExporter new exportTemplate"
| translationLiterals | "translationLiterals is a dictionary of keyword ->#(MethodReference...)."
exportCatalog

| translationLiterals |
translationLiterals := self gatherTranslations.
[stream := exportFile asFileReference ensureDelete; writeStream.
self exportLiteralsDict: translationLiterals]
ensure: [stream close]
[
stream := exportFile asFileReference ensureDelete; writeStream.
self exportLiteralsDict: translationLiterals ] ensure: [ stream close ]
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ gatherTranslations
"Through WATranslatedArgumentsFinder, it finds all 'someString' seasideTranslated
translations, and variations on that (e.g. seasideLazyTranslated)
returns literals, which is a dictionary of 'someString' -> #(MethodReference...)"
found := WATranslatedArgumentsFinder new translatedArguments.
found := WATranslatedArgumentsFinder new translatedArgumentsIn: rbEnvironment.
^ self createStringMethodRefDictionary: found.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
rbEnvironment: aRBBrowserEnvironment
rbEnvironment := aRBBrowserEnvironment
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"classvars" : [ ],
"instvars" : [
"exportFile",
"stream"
"stream",
"rbEnvironment"
],
"name" : "WAGetTextExporter",
"type" : "normal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ translatedArguments: classesToSelect

| env |
env := classesToSelect
ifNil: [ RBBrowserEnvironment new, RBBrowserEnvironment new allMetaClasses ]
ifNil: [ RBBrowserEnvironment new forClasses: RBBrowserEnvironment new allNonMetaClasses, RBBrowserEnvironment new allMetaClasses ]
ifNotNil: [ RBBrowserEnvironment new forClasses: classesToSelect ].
^ self translatedArgumentsIn: env
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
tests - test data
fileContentsOfPOTFile
^'#: Seaside-Gettext-Examples,WAGettextExample>>renderContentOn:,WAGettextExample>>renderContentOn:,WAGettextExample>>renderContentOn:,WAGettextExample>>renderContentOn:,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate,WALocalizationContextTest>>testTranslate
^'#: WAGettextExample>>renderContentOn:
msgid "fontsize"
msgstr ""
#: Seaside-Gettext-Examples,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:
#: WAGettextExample>>renderLocaleSelectionOn:
msgid "Select a locale below"
msgstr ""
#: Seaside-Gettext-Examples,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:
#: WAGettextExample>>renderLocaleSelectionOn:
msgid "locale"
msgstr ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
tests - test data
sortedTriplets

^ #(#('Seaside-Gettext-Examples,WAGettextExample>>#renderContentOn:,fontsize' 'Seaside-Gettext-Examples,WAGettextExample>>renderContentOn:,WAGettextExample>>renderContentOn:,WAGettextExample>>renderContentOn:,WAGettextExample>>renderContentOn:' 'fontsize')
#('Seaside-Gettext-Examples,WAGettextExample>>#renderLocaleSelectionOn:,Select a locale below' 'Seaside-Gettext-Examples,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:' 'Select a locale below')
#('Seaside-Gettext-Examples,WAGettextExample>>#renderLocaleSelectionOn:,locale' 'Seaside-Gettext-Examples,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:' 'locale'))
^ #(
#('WAGettextExample>>#renderContentOn:,fontsize' 'WAGettextExample>>renderContentOn:' 'fontsize') #('WAGettextExample>>#renderLocaleSelectionOn:,Select a locale below' 'WAGettextExample>>renderLocaleSelectionOn:' 'Select a locale below') #('WAGettextExample>>#renderLocaleSelectionOn:,locale' 'WAGettextExample>>renderLocaleSelectionOn:' 'locale'))
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
tests - test data
sortedTripletsString

^ '#: Seaside-Gettext-Examples,WAGettextExample>>renderContentOn:,WAGettextExample>>renderContentOn:,WAGettextExample>>renderContentOn:,WAGettextExample>>renderContentOn:', String lf,
^ '#: WAGettextExample>>renderContentOn:', String lf,
'msgid "fontsize"', String lf,
'msgstr ""', String lf, String cr,
'#: Seaside-Gettext-Examples,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:', String lf,
'#: WAGettextExample>>renderLocaleSelectionOn:', String lf,
'msgid "Select a locale below"', String lf,
'msgstr ""', String lf, String cr,
'#: Seaside-Gettext-Examples,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:,WAGettextExample>>renderLocaleSelectionOn:', String lf,
'#: WAGettextExample>>renderLocaleSelectionOn:', String lf,
'msgid "locale"', String lf,
'msgstr ""', String lf, String cr.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ testExportCatalog
| exporter translationFile |
translationFile := FileLocator temp / 'seaside_gettext_tests.pot'.
self deny: translationFile exists.
exporter := WAGetTextExporter new exportFile: FileLocator temp / 'seaside_gettext_tests.pot'.
exporter := WAGetTextExporter new
rbEnvironment: (RBPackageEnvironment packageName: 'Seaside-Gettext-Examples');
exportFile: FileLocator temp / 'seaside_gettext_tests.pot';
yourself.
[ exporter exportCatalog.
self assert: translationFile exists.
self assert: translationFile contents withInternalLineEndings equals: self fileContentsOfPOTFile. ]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
tests - test data
translationLiteralsArrayAsCompiledMethod
^ {
'Select a locale below'->(OrderedCollection newFrom: {
(WAGettextExample>>#renderLocaleSelectionOn:).
(WAGettextExample>>#renderLocaleSelectionOn:).
(WAGettextExample>>#renderLocaleSelectionOn:).
(WAGettextExample>>#renderLocaleSelectionOn:).
(WAGettextExample>>#renderLocaleSelectionOn:).
(WAGettextExample>>#renderLocaleSelectionOn:).
(WAGettextExample>>#renderLocaleSelectionOn:).
(WAGettextExample>>#renderLocaleSelectionOn:).
}).
'fontsize'->(OrderedCollection newFrom: {
(WAGettextExample>>#renderContentOn:).
(WAGettextExample>>#renderContentOn:).
(WAGettextExample>>#renderContentOn:).
(WAGettextExample>>#renderContentOn:).
}).
'locale'->(OrderedCollection newFrom: {
(WAGettextExample>>#renderLocaleSelectionOn:).
(WAGettextExample>>#renderLocaleSelectionOn:).
(WAGettextExample>>#renderLocaleSelectionOn:).
(WAGettextExample>>#renderLocaleSelectionOn:).
(WAGettextExample>>#renderLocaleSelectionOn:).
(WAGettextExample>>#renderLocaleSelectionOn:).
(WAGettextExample>>#renderLocaleSelectionOn:).
(WAGettextExample>>#renderLocaleSelectionOn:).
})
}.

^ {
('Select a locale below' -> (Set newFrom: { (WAGettextExample >> #renderLocaleSelectionOn:) })).
('fontsize' -> (Set newFrom: { (WAGettextExample >> #renderContentOn:) })).
('locale' -> (Set newFrom: { (WAGettextExample >> #renderLocaleSelectionOn:) })) }

0 comments on commit 74708e1

Please sign in to comment.