22import {
33 getAvailableVersions ,
44 getVersion ,
5- type LanguageData ,
5+ type Language ,
66 type Version ,
77} from ' ./Version' ;
88import {computed , onMounted , ref , watch } from ' vue' ;
99import * as UrlService from ' ./UrlService' ;
10+ import DifferModal from ' ./components/DifferModal.vue' ;
1011
1112type SortBys = ' id' | ' name' ;
1213
@@ -15,6 +16,7 @@ const availableVersions = ref<string[] | null>(null);
1516const wantedVersion = ref <string >(' ' );
1617const version = ref <Version | null >(null );
1718const sortBy = ref <SortBys >(' id' );
19+ const differModal = ref <InstanceType <typeof DifferModal > | null >(null );
1820
1921onMounted (async () => {
2022 availableVersions .value = await getAvailableVersions ();
@@ -29,7 +31,7 @@ async function loadVersion(v: string): Promise<void> {
2931 busy .value = true ;
3032 try {
3133 const loadedVersion = await getVersion (v );
32- if (loadedVersion ._version !== v ) {
34+ if (loadedVersion .version !== v ) {
3335 return ;
3436 }
3537 UrlService .setVersionInUrl (v );
@@ -42,56 +44,55 @@ async function loadVersion(v: string): Promise<void> {
4244 }
4345}
4446watch (wantedVersion , (v ) => {
45- if (v && v !== version .value ?._version ) {
47+ if (v && v !== version .value ?.version ) {
4648 loadVersion (v );
4749 }
4850});
49- export interface Language extends LanguageData {
50- id: string ;
51- }
5251
5352const comparer = new Intl .Collator (' en' , {sensitivity: ' base' });
5453
5554const languages = computed <Language []>(() => {
56- const result: Language [] = [];
5755 if (! version .value ) {
58- return result ;
59- }
60- for (const [id, data] of Object .entries (version .value )) {
61- if (id === ' _version' ) {
62- continue ;
63- }
64- result .push ({id , ... (<LanguageData >data )});
56+ return [];
6557 }
58+ const result = [... version .value .languages ];
6659 result .sort ((a , b ) => comparer .compare (a [sortBy .value ], b [sortBy .value ]));
6760 return result ;
6861});
6962 </script >
7063
7164<template >
72- <div class =" container text-center" v-if =" availableVersions !== null" >
73- <div class =" row justify-content-center" >
74- <label class =" col-sm-2 col-form-label" for =" wanted-version"
75- >Version</label
76- >
77- <div class =" col-md-2 col-sm-4 col-xs-10" >
78- <select
79- id =" wanted-version"
80- v-model =" wantedVersion"
81- :disabled =" busy"
82- class =" form-control"
83- >
84- <option v-for =" v in availableVersions" :value =" v" :key =" v" >
85- {{ v }}
86- </option >
87- </select >
65+ <div class =" container" v-if =" availableVersions !== null" >
66+ <div class =" row justify-content-center mb-3" >
67+ <div class =" col-12" style =" max-width : 300px " >
68+ <div class =" input-group input-group-sm" >
69+ <label for =" wanted-version" class =" input-group-text" >Version</label >
70+ <select
71+ id =" wanted-version"
72+ v-model =" wantedVersion"
73+ :disabled =" busy"
74+ class =" form-control"
75+ >
76+ <option v-for =" v in availableVersions" :value =" v" :key =" v" >
77+ {{ v }}
78+ </option >
79+ </select >
80+ <button
81+ v-if =" version !== null"
82+ type =" button"
83+ class =" btn btn-outline-secondary"
84+ @click =" differModal?.open(version.version)"
85+ >
86+ Compare
87+ </button >
88+ </div >
8889 </div >
8990 </div >
9091 </div >
9192 <div v-if =" version !== null" class =" container-fluid" >
9293 <table class =" table table-sm table-striped table-hover caption-top" >
9394 <caption class =" text-center" >
94- <h2 >gettext plural rules from CLDR {{ version._version }}</h2 >
95+ <h2 >gettext plural rules from CLDR {{ version.version }}</h2 >
9596 </caption >
9697 <thead >
9798 <tr >
@@ -125,7 +126,7 @@ const languages = computed<Language[]>(() => {
125126 <tbody >
126127 <tr
127128 v-for =" language in languages"
128- :key =" `${language.id}@${version._version }`"
129+ :key =" `${language.id}@${version.version }`"
129130 >
130131 <td >
131132 <code >{{ language.id }}</code >
@@ -156,4 +157,5 @@ const languages = computed<Language[]>(() => {
156157 </tbody >
157158 </table >
158159 </div >
160+ <DifferModal ref =" differModal" />
159161</template >
0 commit comments