refactor: reuse capitalize from @vue/shared

Signed-off-by: Fernando Fernández <ferferga@hotmail.com>
This commit is contained in:
Fernando Fernández 2024-05-19 14:06:49 +02:00
parent 68d127f9bc
commit 82a958c59d
No known key found for this signature in database
GPG Key ID: 82FD36644F1F4D3B
3 changed files with 4 additions and 11 deletions

View File

@ -33,7 +33,7 @@ import IMdiSurroundSound71 from 'virtual:icons/mdi/surround-sound-7-1';
import IMdiSurroundSound from 'virtual:icons/mdi/surround-sound';
import { watchImmediate } from '@vueuse/core';
import { getLocaleName } from '@/utils/i18n';
import { upperFirst } from '@/utils/data-manipulation';
import { capitalize } from '@vue/shared';
const props = withDefaults(
defineProps<{
@ -90,7 +90,7 @@ function getTrackIcon(
*/
function getTrackSubtitle(track: MediaStream): string | undefined {
if ((props.type === 'Audio' || props.type === 'Subtitle') && track.Language) {
return upperFirst(
return capitalize(
getLocaleName(track.Language, locale.value)
?? `${t('unknown')} (${track.Language})`
);

View File

@ -24,10 +24,3 @@ export function mergeExcludingUnknown<T extends object, K extends keyof T>(
return object;
}
/**
* Uppercase the first letter of a string
*/
export function upperFirst<T extends string>(str: T): Capitalize<T> {
return (str[0].toUpperCase() + str.slice(1)) as Capitalize<T>;
}

View File

@ -1,4 +1,4 @@
import { upperFirst } from '@/utils/data-manipulation';
import { capitalize } from '@vue/shared';
import { isStr } from '@/utils/validation';
/**
@ -10,7 +10,7 @@ export function getLocaleName(
): string | undefined {
const r = new Intl.DisplayNames([toCode], { type: 'language' }).of(fromCode);
return isStr(r) ? upperFirst(r) : r;
return isStr(r) ? capitalize(r) : r;
}
/**