Add Traditional Chinese search #1862

Merged
merged 3 commits into from Jan 6, 2016

Projects

None yet

5 participants

@enhao
Contributor
enhao commented Apr 22, 2015

No description provided.

@enhao enhao closed this Apr 23, 2015
@enhao enhao reopened this Apr 23, 2015
@daoiqi
Contributor
daoiqi commented Aug 4, 2015

sphinx 1.3.1

I use your commit e862d8864e5f0753b35ae3dd01265d5c28ffbffe

my lang is zh , I update language map.

then I run command make html

Exception:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/sphinx/cmdline.py", line 245, in main
    app.build(opts.force_all, filenames)
  File "/usr/local/lib/python2.7/dist-packages/sphinx/application.py", line 264, in build
    self.builder.build_update()
  File "/usr/local/lib/python2.7/dist-packages/sphinx/builders/__init__.py", line 245, in build_update
    'out of date' % len(to_build))
  File "/usr/local/lib/python2.7/dist-packages/sphinx/builders/__init__.py", line 316, in build
    self.write(docnames, list(updated_docnames), method)
  File "/usr/local/lib/python2.7/dist-packages/sphinx/builders/__init__.py", line 343, in write
    self.prepare_writing(docnames)
  File "/usr/local/lib/python2.7/dist-packages/sphinx/builders/html.py", line 259, in prepare_writing
    self.config.html_search_scorer)
  File "/usr/local/lib/python2.7/dist-packages/sphinx/search/__init__.py", line 231, in __init__
    self.lang = lang_class(options)
  File "/usr/local/lib/python2.7/dist-packages/sphinx/search/__init__.py", line 60, in __init__
    self.init(options)
  File "/usr/local/lib/python2.7/dist-packages/sphinx/search/zh_TW.py", line 249, in init
    if os.path.isfile(dict):
  File "/usr/lib/python2.7/genericpath.py", line 29, in isfile
    st = os.stat(path)
TypeError: coercing to Unicode: need string or buffer, NoneType found

code ->
https://github.com/enhao/sphinx/blob/8694088b4cc4b571d4e89852e29c5622bcdb3f74/sphinx/search/zh_TW.py#L248

options value is {}

need to set html_search_options in conf.py?


it is OK.

vim conf.py

# add this code to sphinx conf.py
import jieba
html_search_options = {'dict': jieba.DEFAULT_DICT}
@daoiqi
Contributor
daoiqi commented Aug 4, 2015

how about to set default dict path?

https://github.com/enhao/sphinx/blob/8694088b4cc4b571d4e89852e29c5622bcdb3f74/sphinx/search/zh_TW.py#L248

if JIEBA:
    dict = options.get('dict', jieba.DEFAULT_DICT)  # jieba module is intalled .
    if os.path.isfile(dict):
        jieba.set_dictionary(dict)
        print
        print "Dictionary path:", dict
@daoiqi
Contributor
daoiqi commented Aug 14, 2015

When can merge into the master? It is exciting features. @shimizukawa @birkenfeld

@daoiqi
Contributor
daoiqi commented Aug 27, 2015

I run make check to check code. when utils/check_source.py check file , it will compare module name lowercase with filename. So sphinx.search.zh_TW.py fail.

see the check code .https://github.com/sphinx-doc/sphinx/blob/master/utils/check_sources.py#L119

I am confused that zh_TW.py can rename zh.py to support chinese search? Or rename zh_tw.py?

@shimizukawa
Member

@daoiqi IMO, zh_tw.py is better as a python module name.

@tk0miya tk0miya added the html search label Dec 19, 2015
@birkenfeld birkenfeld merged commit e862d88 into sphinx-doc:master Jan 6, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment