/* New default dir. Check if its an old named dir. We want to
reuse that if it exists. */
compat_dir = lookup_backwards_compat (default_dir);
if (compat_dir)
{
path_name = concat_strings (get_home_dir (), "/", compat_dir->path, NULL);
if (!is_directory (path_name))
{
free (path_name);
path_name = NULL;
}
else
relative_path_name = strdup (compat_dir->path);
}
}
if (path_name == NULL)
{
translated_name = localize_path_name (default_dir->path);
relative_path_name = filename_from_utf8 (translated_name);
if (relative_path_name == NULL)
通过光盘启动后, 进入安装界面, 此时按ctrl+ alt+f1进入到字符界面, 可以看到桌面文件夹Deskto p已经创建了, 这时是英文的, 即便当前的环境变量LANG为z h_CN.UTF- 8。
在安装界面,如果点击试用而进入 到试用状态,在这个进入的过程中 会调用xdg- user-dirs- update创建个人目录: 桌面,公共的, 图片,音乐,模板, ……,等。
通过分析xdg- user-dirs- update的源代码, 发现它里面有个后续兼容目录ba ckwards_ compat_ dirs的判断, 当已经存在Desktop目录时 ,就会跳过翻译:
/* New default dir. Check if its an old named dir. We want to backwards_ compat (default_dir); path_name = strdup (compat_dir->path);
reuse that if it exists. */
compat_dir = lookup_
if (compat_dir)
{
path_name = concat_strings (get_home_dir (), "/", compat_dir->path, NULL);
if (!is_directory (path_name))
{
free (path_name);
path_name = NULL;
}
else
relative_
}
}
if (path_name == NULL) dir->path) ; path_name = filename_from_utf8 (translated_name);
{
translated_name = localize_path_name (default_
relative_
if (relative_path_name == NULL)
也就是上面代码中, compat_ dir为真,! is_directory( )为假,导致path_ name为真, 从而后续的localize_ path_name( )的翻译就没调到, 因此这个bug就来了。
在安装好系统后, 新建用户,然后以新建用户登录系 统,此时因为没有提前存在Des ktop目录, 所以就能够直接创建出新的被lo calize_ path_name( )的“桌面”。