This repository was archived by the owner on Dec 12, 2020. It is now read-only.
  
  
  
  
    
    
    
      
    
  
  
    
File tree Expand file tree Collapse file tree 5 files changed +98
-6
lines changed Expand file tree Collapse file tree 5 files changed +98
-6
lines changed Original file line number Diff line number Diff line change 3232-  [ Spying On ` window.alert ` ] ( #spying-window-alert ) 
3333-  [ Tests] ( cypress/integration/counter-vuex-spec.js )  for a component that [ uses Vuex data store] ( components/Counter.vue ) 
3434-  [ Tests] ( cypress/integration/router-spec.js )  for a component that [ uses vue-router] ( components/PizzaShop ) 
35+ -  [ translated-message-spec.js] ( cypress/integration/translated-message-spec.js )  shows how to test [ TranslatedMessage.vue] ( components/TranslatedMessage.vue )  component that uses [ Vue-i18n] ( http://kazupon.github.io/vue-i18n/en/ ) 
3536
3637[ Bundling] ( #bundling ) 
3738-  [ Short Way] ( #short-way ) 
Original file line number Diff line number Diff line change 1+ <!--  uses special loader to load i18n blocks --> 
2+ <!--  see http://kazupon.github.io/vue-i18n/en/sfc.html --> 
3+ <i18n >
4+ {
5+   "en": {
6+     "hello": "hello world!"
7+   },
8+   "fa": {
9+     "hello": "سلام دنیا"
10+   },
11+   "ja": {
12+     "hello": "こんにちは、世界"
13+   },
14+   "ru": {
15+     "hello": "Привет мир"
16+   }
17+ }
18+ </i18n >
19+ 
20+ <template >
21+   <div  id =" app" 
22+     <label  for =" locale" label >
23+     <select  v-model =" locale" 
24+       <option >en</option >
25+       <option >fa</option >
26+       <option >ja</option >
27+       <option >ru</option >
28+     </select >
29+     <p >message: {{ $t('hello') }}</p >
30+   </div >
31+ </template >
32+ 
33+ <script >
34+ export  default  {
35+   name:  ' app'  
36+   data  () { return  { locale:  ' en'  
37+   watch:  { 
38+     locale  (val ) { 
39+       this .$i18n .locale  =  val 
40+     } 
41+   } 
42+ } 
43+ script >
Original file line number Diff line number Diff line change 1+ // testing i18n component 
2+ // http://kazupon.github.io/vue-i18n 
3+ import  TranslatedMessage  from  '../../components/TranslatedMessage.vue' 
4+ import  VueI18n  from  'vue-i18n' 
5+ import  mountVue  from  '../..' 
6+ 
7+ /* eslint-env mocha */ 
8+ describe ( 'VueI18n' ,  ( )  =>  { 
9+   // need to use VueI18n as a plugin 
10+   const  extensions  =  { 
11+     plugins : [ VueI18n ] , 
12+     components : { 
13+       TranslatedMessage
14+     } 
15+   } 
16+ 
17+   const  template  =  '<translated-message />' 
18+ 
19+   beforeEach ( mountVue ( { template} ,  { extensions} ) ) 
20+ 
21+   it ( 'shows English, Japanese and Russian greeting' ,  ( )  =>  { 
22+     cy . viewport ( 400 ,  200 ) 
23+ 
24+     cy . get ( 'select' ) . select ( 'en' ) . should ( 'have.value' ,  'en' ) 
25+     cy . contains ( 'message: hello' ) 
26+ 
27+     cy . get ( 'select' ) . select ( 'fa' ) . should ( 'have.value' ,  'fa' ) 
28+     cy . contains ( 'message: سلام دنیا' ) 
29+ 
30+     cy . get ( 'select' ) . select ( 'ja' ) . should ( 'have.value' ,  'ja' ) 
31+     cy . contains ( 'message: こんにちは、世界' ) 
32+ 
33+     cy . get ( 'select' ) . select ( 'ru' ) . should ( 'have.value' ,  'ru' ) 
34+     cy . contains ( 'message: Привет мир' ) 
35+   } ) 
36+ 
37+   // TODO how to load messages not from i18n block but from external JSON file? 
38+   // then we could reuse the messages to check the contents 
39+ } ) 
Original file line number Diff line number Diff line change 7878    }
7979  },
8080  "devDependencies" : {
81-     "babel-plugin-transform-object-rest-spread" : " 6.26.0" 
8281    "axios" : " 0.18.0" 
82+     "babel-plugin-transform-object-rest-spread" : " 6.26.0" 
8383    "ban-sensitive-files" : " 1.9.2" 
8484    "css-loader" : " 0.28.11" 
85+     "cypress" : " 2.1.0" 
8586    "dependency-check" : " 3.1.0" 
8687    "deps-ok" : " 1.4.0" 
8788    "git-issues" : " 1.3.1" 
9091    "nsp" : " 3.2.1" 
9192    "pre-git" : " 3.17.1" 
9293    "prettier-standard" : " 8.0.1" 
93-     "simple-commit-message" : " 4.0.3" 
9494    "semantic-release" : " 15.1.7" 
95+     "simple-commit-message" : " 4.0.3" 
9596    "standard" : " 11.0.1" 
9697    "vue" : " 2.5.16" 
98+     "vue-i18n" : " 7.6.0" 
9799    "vue-loader" : " 14.2.2" 
98-     "vuex" : " 3.0.1" 
99100    "vue-router" : " 3.0.1" 
100101    "vue-template-compiler" : " 2.5.16" 
101-     "cypress " : " 2.1.0 " 
102+     "vuex " : " 3.0.1 " 
102103  },
103104  "standard" : {
104105    "globals" : [
113114  },
114115  "dependencies" : {
115116    "@cypress/webpack-preprocessor" : " 2.0.1" 
116-     "common-tags" : " 1.7.2" 
117+     "common-tags" : " 1.7.2" 
118+     "@kazupon/vue-i18n-loader" : " 0.3.0" 
117119  }
118120}
Original file line number Diff line number Diff line change @@ -11,7 +11,14 @@ const webpackOptions = {
1111    rules : [ 
1212      { 
1313        test : / \. v u e $ / , 
14-         loader : 'vue-loader' 
14+         loader : 'vue-loader' , 
15+         options : { 
16+           loaders : { 
17+             // you need to specify `i18n` loaders key with 
18+             // `vue-i18n-loader` (https://github.com/kazupon/vue-i18n-loader) 
19+             i18n : '@kazupon/vue-i18n-loader' 
20+           } 
21+         } 
1522      } 
1623    ] 
1724  } 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments