Question2Answer fully supports non-English languages and is easy to translate. Before proceeding, it’s worth checking here to see if a translation is already available. You may be able to use this immediately, or only have to add some missing phrases.
To create a new Question2Answer translation from scratch, follow the steps below:
qa-includedirectory and look at the function
qa_admin_language_options(). This contains an array which maps abbreviated language codes to their corresponding languages. For example, the abbreviation for Russian is
ru. Note down the abbreviation for your language. If your language is not in the array, you may add it, but please also tell us so we can include it in future versions.
qa-langdirectory, and name the subdirectory with the abbreviation for your language, keeping the original capitalization.
qa-lang-*.phpfiles in Question2Answer’s
qa-includedirectory to the new language directory you created. This is currently a total of 8 files.
qa-lang-*.phpfiles that you created. To translate each file:
=>symbol to your language.
^). These can be moved but not removed. In some cases, the
^symbol is followed by a number or word, such as
^site_title, and this should also be preserved.
=>on each line.
qa-lang-options.php- these are only used for the admin interface and do not contain any phrases which are visible to normal users of Q2A.
qa-lang-*.phpfile you are working on, then viewing or refreshing the appropriate pages in your browser.
qa-check-lang.phpis your friend! As you work, use your web browser to view the
qa-include/qa-check-lang.phppage within your Question2Answer site. This will check your language files for any omitted phrases or substitutions.
An incomplete Question2Answer translation may be available for your language, for example because it has not been updated for the latest version of Q2A. To update a translation for the version you are running, follow the steps below:
ru) in Q2A’s
qa-check-lang.phpis your best friend! Use your web browser to view the
qa-include/qa-check-lang.phppage within your Question2Answer site. This will check your language files for errors and auto-generate the PHP code for missing phrases.
qa-lang-*.phpfile that needs attention:
qa-include/qa-check-lang.phpinto the middle of this file.
=>symbol to your language.
^). These can be moved but not removed.
qa-include/qa-check-lang.phpin your web browser and ensure that you resolve all issues shown. You can also browse around your Q2A site to see how the translated phrases are used in context.
From version 1.4, it is possible to modify some of the URLs used within a Q2A site. For example,
http://mysite.com/questions could be replaced with
http://mysite.com/proposals. To do this, look for the commented
$QA_CONST_PATH_MAP definition in
qa-config.php. This shows an example of how to define a PHP array which modifies the standard URLs used.
Starting in version 1.5, it is also possible to customize specific language phrases for your Q2A site without installing a full translation. To customize a particular phrase, follow the steps below:
qa-include/qa-lang-*.phpfiles to find the file and line containing the phrase.
qa-lang-*.php file in Q2A’s
qa-lang/custom directory, with the same name as the file that you found in the previous step, and paste in the following code:
<?php return array( // custom phrases go here... );
qa-lang-*.phpfile into the middle of the
array( )in your new file.
=>symbol to suit your requirements. Pay attention to substitution points, which use the hat symbol (
^). For non-English languages, ensure your text editor is using UTF-8 encoding without a BOM (byte order mark).
Below is an example
qa-lang/custom/qa-lang-main.php file which modifies the ‘Hello [username]’ and ‘My Account’ phrases:
<?php return array( 'logged_in_x' => 'Welcome, ^!', 'nav_account' => 'My Settings', );