Skip to content

check ui language #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions code-nautilus.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@
# always create new window?
NEWWINDOW = False

# ui language check
lang = os.environ.get("LANG")
label = ""
if "zh" in lang:
label = '在 ' + VSCODENAME + ' 中打开'
tip_files = '用 VSCode 打开所选择的文件'
tip_backgroud = '在 VSCode 中打开当前目录'
else:
label = 'Open in ' + VSCODENAME
tip_files = 'Opens the selected files with VSCode'
tip_backgroud = 'Opens the current directory in VSCode'

class VSCodeExtension(GObject.GObject, Nautilus.MenuProvider):

Expand All @@ -45,8 +56,8 @@ def launch_vscode(self, menu, files):
def get_file_items(self, window, files):
item = Nautilus.MenuItem(
name='VSCodeOpen',
label='Open in ' + VSCODENAME,
tip='Opens the selected files with VSCode'
label=label,
tip=tip_files
)
item.connect('activate', self.launch_vscode, files)

Expand All @@ -55,8 +66,8 @@ def get_file_items(self, window, files):
def get_background_items(self, window, file_):
item = Nautilus.MenuItem(
name='VSCodeOpenBackground',
label='Open in ' + VSCODENAME,
tip='Opens the current directory in VSCode'
label=label,
tip=tip_backgroud
)
item.connect('activate', self.launch_vscode, [file_])

Expand Down