Quellcode durchsuchen

make “authenticate with” translatable with i18n

Artur Paikin vor 6 Jahren
Ursprung
Commit
103116e48c

+ 4 - 1
packages/@uppy/core/src/index.js

@@ -53,7 +53,9 @@ class Uppy {
         logOut: 'Log out',
         filter: 'Filter',
         resetFilter: 'Reset filter',
-        loading: 'Loading...'
+        loading: 'Loading...',
+        authenticateWithTitle: 'Please authenticate with %{pluginName} to select files',
+        authenticateWith: 'Connect to %{pluginName}'
       }
     }
 
@@ -83,6 +85,7 @@ class Uppy {
     this.translator = new Translator([ this.defaultLocale, this.opts.locale ])
     this.locale = this.translator.locale
     this.i18n = this.translator.translate.bind(this.translator)
+    this.i18nArray = this.translator.translateArray.bind(this.translator)
 
     // Container for different types of plugins
     this.plugins = {}

+ 7 - 2
packages/@uppy/provider-views/src/AuthView.js

@@ -9,16 +9,21 @@ class AuthBlock extends Component {
   }
 
   render () {
+    const pluginNameComponent = (
+      <span class="uppy-Provider-authTitleName">{this.props.pluginName}<br /></span>
+    )
     return <div class="uppy-Provider-auth">
       <div class="uppy-Provider-authIcon">{this.props.pluginIcon()}</div>
-      <h1 class="uppy-Provider-authTitle">Please authenticate with <span class="uppy-Provider-authTitleName">{this.props.pluginName}</span><br /> to select files</h1>
+      <div class="uppy-Provider-authTitle">
+        {this.props.i18nArray('authenticateWithTitle', { pluginName: pluginNameComponent })}
+      </div>
       <button
         type="button"
         class="uppy-u-reset uppy-c-btn uppy-c-btn-primary uppy-Provider-authBtn"
         onclick={this.props.handleAuth}
         ref={(el) => { this.connectButton = el }}
       >
-        Connect to {this.props.pluginName}
+        {this.props.i18nArray('authenticateWith', { pluginName: this.props.pluginName })}
       </button>
       {this.props.demo &&
         <button class="uppy-u-reset uppy-c-btn uppy-c-btn-primary uppy-Provider-authBtn" onclick={this.props.handleDemoAuth}>Proceed with Demo Account</button>

+ 3 - 1
packages/@uppy/provider-views/src/index.js

@@ -536,7 +536,9 @@ module.exports = class ProviderView {
             pluginIcon={this.plugin.icon}
             demo={this.plugin.opts.demo}
             handleAuth={this.handleAuth}
-            handleDemoAuth={this.handleDemoAuth} />
+            handleDemoAuth={this.handleDemoAuth}
+            i18n={this.plugin.uppy.i18n}
+            i18nArray={this.plugin.uppy.i18nArray} />
         </CloseWrapper>
       )
     }