Skip to content

Commit 53cd7f9

Browse files
authored
Vue Localization Fixes (#963)
* add additional string for vue to localization: - update babel config to be compatible with latest jinja - add .vue extractor (babel-vue-extractor) to i18n requirements - update .vue files to render localizable attributes with localization - update vue_loc.html to include additional runtime strings to be looked up server-side - fixes #875 * tests: fix tests to use example-com.webrecorder.net
1 parent 586fa48 commit 53cd7f9

File tree

9 files changed

+65
-87
lines changed

9 files changed

+65
-87
lines changed

babel.ini

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
[jinja2: pywb/templates/**.html]
2-
extensions=jinja2.ext.i18n,jinja2.ext.autoescape,jinja2.ext.with_
2+
extensions=jinja2.ext.i18n
3+
encoding=utf-8
4+
5+
[babelvueextractor.extract.extract_vue: pywb/vueui/src/**.vue]
6+
[babelvueextractor.extract.extract_vue: pywb/vueui/src/components/**.vue]
7+
encoding=utf-8

extra_requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ pysocks
77
lxml
88
babel
99
translate_toolkit
10+
babel-vue-extractor

pywb/apps/test/test_rewriter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ def setup_class(cls):
2323
config_file=None))
2424

2525
def test_replay(self):
26-
resp = self.testapp.get('/live/mp_/http://example.com/')
26+
resp = self.testapp.get('/live/mp_/https://example-com.webrecorder.net/')
2727
resp.charset = 'utf-8'
2828

2929
assert '"http://localhost:80/live/mp_/https://www.iana.org/domains/example"' in resp.text
3030

31-
assert '"http://example.com/"'
31+
assert '"https://example-com.webrecorder.net/"' in resp.text
3232

3333
def test_top_frame(self):
34-
resp = self.testapp.get('/live/http://example.com/')
34+
resp = self.testapp.get('/live/https://example-com.webrecorder.net/')
3535
resp.charset = 'utf-8'
3636

37-
assert '"http://example.com/"' in resp.text
37+
assert '"https://example-com.webrecorder.net/"' in resp.text
3838

3939
#def test_cookie_track_1(self):
4040
# resp = self.testapp.get('/live/mp_/https://twitter.com/')

pywb/static/vue/vueui.js

Lines changed: 34 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pywb/templates/vue_loc.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,15 @@
6161
"Current Capture": "{{ _Q('Current Capture') }}",
6262
"capture": "{{ _Q('capture') }}",
6363
"captures": "{{ _Q('captures') }}",
64+
"{count} capture": "{{ _Q('{count} capture') }}",
65+
"View capture on {date}": "{{ _Q('View capture on {date}') }}",
6466
"from {hour1} to {hour2}": "{{ _Q('from {hour1} to {hour2}') }}",
6567
"no captures": "{{ _Q('no captures') }}",
66-
"Archived Page: ": "{{ _Q('Archived Page: ') }}"
68+
"Archived Page: ": "{{ _Q('Archived Page: ') }}",
69+
"Zoom out to {id} ({count} captures)": "{{ _Q('Zoom out to {id} ({count} captures)') }}",
70+
"Language:": "{{ _Q('Language') }}",
71+
"Search for archival capture of URL": "{{ _Q('Search for archival capture of URL') }}",
72+
"Toggle navigation": "{{ _Q('Toggle navigation') }}",
73+
"Logo": "{{ _Q('Logo') }}",
6774
}
6875
</script>

pywb/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '2.9.1'
1+
__version__ = '2.10.0b0'
22

33
if __name__ == '__main__':
44
print(__version__)

pywb/vueui/src/App.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
class="navbar navbar-light navbar-expand-lg fixed-top top-navbar justify-content-center"
66
:style="navbarStyle">
77
<a class="navbar-brand flex-grow-1 my-1" :href="config.logoHomeUrl" v-if="config.logoHomeUrl">
8-
<img :src="config.logoImg" id="logo-img" alt="_('pywb logo')">
8+
<img :src="config.logoImg" id="logo-img" :alt="_('Logo')">
99
</a>
1010
<div class="navbar-brand flex-grow-1 my-1" v-else>
11-
<img :src="config.logoImg" id="logo-img" alt="_('pywb logo')">
11+
<img :src="config.logoImg" id="logo-img" :alt="_('Logo')">
1212
</div>
1313
<div class="flex-grow-1 d-flex" id="searchdiv">
1414
<form
@@ -20,8 +20,8 @@
2020
type="text"
2121
:value="config.url"
2222
height="31"
23-
aria-label="_('Search for archival capture of URL')"
24-
title="_('Search for archival capture of URL')"></input>
23+
:aria-label="_('Search for archival capture of URL')"
24+
:title="_('Search for archival capture of URL')"></input>
2525
</form>
2626
</div>
2727
<button
@@ -32,7 +32,7 @@
3232
data-target="#navbarCollapse"
3333
aria-controls="navbarCollapse"
3434
aria-expanded="false"
35-
aria-label="_('Toggle navigation')">
35+
:aria-label="_('Toggle navigation')">
3636
<span class="navbar-toggler-icon"></span>
3737
</button>
3838
<div class="collapse navbar-collapse ml-auto" id="navbarCollapse">
@@ -98,7 +98,7 @@
9898
aria-haspopup="true"
9999
aria-expanded="false"
100100
:title="_('Select language')">
101-
<i class="fas fa-globe-africa" :title="_('Language')"></i>
101+
<i class="fas fa-globe-africa" :title="_('Language:')"></i>
102102
</button>
103103
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="locale-dropdown">
104104
<a

pywb/vueui/src/components/TimelineBreadcrumbs.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
</template>
3232

3333
<script>
34+
import {PywbI18N} from "../i18n";
35+
3436
export default {
3537
props: {
3638
period: {
@@ -44,7 +46,7 @@ export default {
4446
},
4547
methods: {
4648
getPeriodZoomOutText(period) {
47-
return 'Zoom out to '+period.getReadableId(true)+ ' ('+period.snapshotCount+' captures)';
49+
return PywbI18N.instance._("Zoom out to {id} ({count} captures)", {id: period.getReadableId(true), count: period.snapshotCount});
4850
},
4951
changePeriod(period) {
5052
if (period.snapshotCount) {

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ def get_package_data():
123123
extras_require={
124124
"i18n": [
125125
"babel",
126-
"translate_toolkit"
126+
"translate_toolkit",
127+
"babel-vue-extractor"
127128
],
128129
},
129130
python_requires='>=3.7,<3.13',

0 commit comments

Comments
 (0)