Skip to content

Commit

Permalink
s3:// links not always titled as being from "Amazon". Defaults to S3,…
Browse files Browse the repository at this point in the history
… can be customized via language file. #408
  • Loading branch information
m-mohr committed Feb 23, 2024
1 parent ec6c409 commit 60855dc
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 12 deletions.
24 changes: 18 additions & 6 deletions src/components/HrefActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import Utils, { browserProtocols, imageMediaTypes, mapMediaTypes } from '../util
import { mapGetters } from 'vuex';
import AssetActions from '../../assetActions.config';
import LinkActions from '../../linkActions.config';
import URI from 'urijs';
export default {
name: 'HrefActions',
Expand Down Expand Up @@ -115,7 +116,7 @@ export default {
}
},
isGdalVfs() {
return Utils.isGdalVfsUri(this.data.href);
return Utils.isGdalVfsUri(this.href);
},
href() {
if (typeof this.data.href !== 'string') {
Expand All @@ -129,11 +130,11 @@ export default {
},
from() {
if (this.isGdalVfs) {
let type = this.data.href.match(/^\/vsi([a-z\d]+)(_streaming)?\//);
return this.protocolName(type);
let type = this.href.match(/^\/vsi([a-z\d]+)(_streaming)?\//);
return this.protocolName(type, this.href);
}
else {
return this.protocolName(this.protocol);
return this.protocolName(this.protocol, this.href);
}
},
browserCanOpenFile() {
Expand Down Expand Up @@ -168,13 +169,24 @@ export default {
}
},
methods: {
protocolName(protocol) {
protocolName(protocol, href = null) {
if (typeof protocol !== 'string') {
return '';
}
switch(protocol.toLowerCase()) {
case 's3':
return this.$t('protocol.s3');
if (href) {
try {
const uri = new URI(href);
const key = `protocol.s3.${uri.domain()}`;
if (this.$te(key)) {
return this.$t(key);
}
} catch (e) {
// Fall back to the default
}
}
return this.$t('protocol.s3.default');
case 'abfs':
case 'abfss':
return this.$t('protocol.azure');
Expand Down
5 changes: 4 additions & 1 deletion src/locales/de/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@
"ftp": "FTP",
"gcs": "Google Cloud",
"oss": "Alibaba Cloud",
"s3": "Amazon S3"
"s3": {
"default": "S3",
"amazonaws.com": "Amazon S3"
}
},
"providers": {
"email": "E-Mail senden",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/en/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@
"ftp": "FTP",
"gcs": "Google Cloud",
"oss": "Alibaba Cloud",
"s3": "Amazon S3"
"s3": {
"default": "S3",
"amazonaws.com": "Amazon S3"
}
},
"providers": {
"email": "Send e-mail",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/es/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@
"ftp": "FTP",
"gcs": "Google Cloud",
"oss": "Alibaba Cloud",
"s3": "Amazon S3"
"s3": {
"default": "S3",
"amazonaws.com": "Amazon S3"
}
},
"providers": {
"email": "Enviar e-mail",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/fr/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@
"ftp": "FTP",
"gcs": "Google Cloud",
"oss": "Alibaba Cloud",
"s3": "Amazon S3"
"s3": {
"default": "S3",
"amazonaws.com": "Amazon S3"
}
},
"providers": {
"email": "Envoyer un courriel",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/it/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@
"ftp": "FTP",
"gcs": "Google Cloud",
"oss": "Alibaba Cloud",
"s3": "Amazon S3"
"s3": {
"default": "S3",
"amazonaws.com": "Amazon S3"
}
},
"providers": {
"email": "Invia e-mail",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/ro/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@
"ftp": "FTP",
"gcs": "Google Cloud",
"oss": "Alibaba Cloud",
"s3": "Amazon S3"
"s3": {
"default": "S3",
"amazonaws.com": "Amazon S3"
}
},
"providers": {
"email": "Trimite un email",
Expand Down

0 comments on commit 60855dc

Please sign in to comment.