Add regional indicators
This commit is contained in:
parent
980241c1ac
commit
cc58b9b93d
@ -47,8 +47,8 @@ const UNICODE_EMOJI_GROUP_ICON = {
|
|||||||
flags: 'flag'
|
flags: 'flag'
|
||||||
}
|
}
|
||||||
|
|
||||||
const maybeLocalizedKeywords = (emoji, languages) => {
|
const maybeLocalizedKeywords = (emoji, languages, nameLocalizer) => {
|
||||||
const res = [emoji.displayText]
|
const res = [emoji.displayText, nameLocalizer(emoji)]
|
||||||
if (emoji.annotations) {
|
if (emoji.annotations) {
|
||||||
languages.forEach(lang => {
|
languages.forEach(lang => {
|
||||||
const keywords = emoji.annotations[lang]?.keywords || []
|
const keywords = emoji.annotations[lang]?.keywords || []
|
||||||
@ -59,13 +59,13 @@ const maybeLocalizedKeywords = (emoji, languages) => {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
const filterByKeyword = (list, keyword = '', languages) => {
|
const filterByKeyword = (list, keyword = '', languages, nameLocalizer) => {
|
||||||
if (keyword === '') return list
|
if (keyword === '') return list
|
||||||
|
|
||||||
const keywordLowercase = keyword.toLowerCase()
|
const keywordLowercase = keyword.toLowerCase()
|
||||||
const orderedEmojiList = []
|
const orderedEmojiList = []
|
||||||
for (const emoji of list) {
|
for (const emoji of list) {
|
||||||
const indices = maybeLocalizedKeywords(emoji, languages)
|
const indices = maybeLocalizedKeywords(emoji, languages, nameLocalizer)
|
||||||
.map(k => k.toLowerCase().indexOf(keywordLowercase))
|
.map(k => k.toLowerCase().indexOf(keywordLowercase))
|
||||||
.filter(k => k > -1)
|
.filter(k => k > -1)
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ const EmojiPicker = {
|
|||||||
this.showingStickers = value
|
this.showingStickers = value
|
||||||
},
|
},
|
||||||
filterByKeyword (list, keyword) {
|
filterByKeyword (list, keyword) {
|
||||||
return filterByKeyword(list, keyword, this.languages)
|
return filterByKeyword(list, keyword, this.languages, this.maybeLocalizedEmojiName)
|
||||||
},
|
},
|
||||||
initializeLazyLoad () {
|
initializeLazyLoad () {
|
||||||
this.destroyLazyLoad()
|
this.destroyLazyLoad()
|
||||||
@ -305,7 +305,6 @@ const EmojiPicker = {
|
|||||||
}, 500)
|
}, 500)
|
||||||
},
|
},
|
||||||
languages () {
|
languages () {
|
||||||
console.log('languages:', ensureFinalFallback(this.$store.getters.mergedConfig.interfaceLanguage))
|
|
||||||
return ensureFinalFallback(this.$store.getters.mergedConfig.interfaceLanguage)
|
return ensureFinalFallback(this.$store.getters.mergedConfig.interfaceLanguage)
|
||||||
},
|
},
|
||||||
maybeLocalizedEmojiName () {
|
maybeLocalizedEmojiName () {
|
||||||
@ -314,6 +313,10 @@ const EmojiPicker = {
|
|||||||
return emoji.displayText
|
return emoji.displayText
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (emoji.displayTextI18n) {
|
||||||
|
return this.$t(emoji.displayTextI18n.key, emoji.displayTextI18n.args)
|
||||||
|
}
|
||||||
|
|
||||||
for (const lang of this.languages) {
|
for (const lang of this.languages) {
|
||||||
if (emoji.annotations[lang]?.name) {
|
if (emoji.annotations[lang]?.name) {
|
||||||
return emoji.annotations[lang].name
|
return emoji.annotations[lang].name
|
||||||
|
@ -211,7 +211,8 @@
|
|||||||
"travel-and-places": "Travel & Places"
|
"travel-and-places": "Travel & Places"
|
||||||
},
|
},
|
||||||
"load_all_hint": "Loaded first {saneAmount} emoji, loading all emoji may cause performance issues.",
|
"load_all_hint": "Loaded first {saneAmount} emoji, loading all emoji may cause performance issues.",
|
||||||
"load_all": "Loading all {emojiAmount} emoji"
|
"load_all": "Loading all {emojiAmount} emoji",
|
||||||
|
"regional_indicator": "Regional indicator {letter}"
|
||||||
},
|
},
|
||||||
"errors": {
|
"errors": {
|
||||||
"storage_unavailable": "Pleroma could not access browser storage. Your login or your local settings won't be saved and you might encounter unexpected issues. Try enabling cookies."
|
"storage_unavailable": "Pleroma could not access browser storage. Your login or your local settings won't be saved and you might encounter unexpected issues. Try enabling cookies."
|
||||||
|
@ -16,6 +16,26 @@ const SORTED_EMOJI_GROUP_IDS = [
|
|||||||
'flags'
|
'flags'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const REGIONAL_INDICATORS = (() => {
|
||||||
|
const start = 0x1F1E6
|
||||||
|
const end = 0x1F1FF
|
||||||
|
const A = 'A'.codePointAt(0)
|
||||||
|
const res = new Array(end - start + 1)
|
||||||
|
for (let i = start; i <= end; ++i) {
|
||||||
|
const letter = String.fromCodePoint(A + i - start)
|
||||||
|
res[i - start] = {
|
||||||
|
replacement: String.fromCodePoint(i),
|
||||||
|
imageUrl: false,
|
||||||
|
displayText: 'regional_indicator_' + letter,
|
||||||
|
displayTextI18n: {
|
||||||
|
key: 'emoji.regional_indicator',
|
||||||
|
args: { letter }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
})()
|
||||||
|
|
||||||
const defaultState = {
|
const defaultState = {
|
||||||
// Stuff from apiConfig
|
// Stuff from apiConfig
|
||||||
name: 'Pleroma FE',
|
name: 'Pleroma FE',
|
||||||
@ -129,6 +149,11 @@ const injectAnnotations = (emoji, annotations) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const injectRegionalIndicators = groups => {
|
||||||
|
groups.symbols.push(...REGIONAL_INDICATORS)
|
||||||
|
return groups
|
||||||
|
}
|
||||||
|
|
||||||
const instance = {
|
const instance = {
|
||||||
state: defaultState,
|
state: defaultState,
|
||||||
mutations: {
|
mutations: {
|
||||||
@ -219,7 +244,7 @@ const instance = {
|
|||||||
}))
|
}))
|
||||||
return res
|
return res
|
||||||
}, {})
|
}, {})
|
||||||
commit('setInstanceOption', { name: 'emoji', value: emoji })
|
commit('setInstanceOption', { name: 'emoji', value: injectRegionalIndicators(emoji) })
|
||||||
} else {
|
} else {
|
||||||
throw (res)
|
throw (res)
|
||||||
}
|
}
|
||||||
@ -234,7 +259,7 @@ const instance = {
|
|||||||
|
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
langList
|
langList
|
||||||
.forEach(async lang => {
|
.map(async lang => {
|
||||||
if (!state.unicodeEmojiAnnotations[lang]) {
|
if (!state.unicodeEmojiAnnotations[lang]) {
|
||||||
const annotations = await loadAnnotations(lang)
|
const annotations = await loadAnnotations(lang)
|
||||||
commit('setUnicodeEmojiAnnotations', { lang, annotations })
|
commit('setUnicodeEmojiAnnotations', { lang, annotations })
|
||||||
|
Loading…
Reference in New Issue
Block a user