Skip to content

Commit

Permalink
feat: optimize track title and update Chinese translation
Browse files Browse the repository at this point in the history
  • Loading branch information
dyphire committed Sep 3, 2024
1 parent 3621e0b commit 5d81d9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/uosc/intl/zh-hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"Loop file": "单个循环",
"Loop playlist": "列表循环",
"Menu": "菜单",
"Move down": "下移",
"Move up": "上移",
"Navigation": "导航",
"Next": "下一个",
"Next page": "下一页",
Expand Down
13 changes: 12 additions & 1 deletion src/uosc/lib/menus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ function create_select_tracklist_type_menu_opener(opts)
end

local track_prop_index, snd_prop_index = get_props()
local filename = mp.get_property_native('filename/no-ext')
local escaped_filename = string.gsub(filename --[[@as string]], '[%(%)%.%+%-%*%?%[%]%^%$%%]', '%%%1')
local first_item_index = #items + 1
local active_index = nil
local disabled_item = nil
Expand Down Expand Up @@ -252,7 +254,16 @@ function create_select_tracklist_type_menu_opener(opts)
if track['demux-samplerate'] then h(string.format('%.3gkHz', track['demux-samplerate'] / 1000)) end
if track.forced then h(t('forced')) end
if track.default then h(t('default')) end
if track.external then h(t('external')) end
if track.external then
local extension = track.title:match('%.([^%.]+)$')
if track.title and extension then
track.title = track.title:gsub(escaped_filename .. '%.?', ''):gsub('%.?([^%.]+)$', '')
if track.lang and track.title:lower() == track.lang:lower() then
track.title = nil
end
end
h(t('external'))
end

items[#items + 1] = {
title = (track.title and track.title or t('Track %s', track.id)),
Expand Down

0 comments on commit 5d81d9c

Please sign in to comment.