# Path: safe/common/utilities.py
# def safe_dir(sub_dir=None):
#     """Absolute path from safe package directory.
# 
#     :param sub_dir: Sub directory relative to safe package directory.
#     :type sub_dir: str
# 
#     :return: The Absolute path.
#     :rtype: str
#     """
#     safe_relative_path = os.path.join(
#         os.path.dirname(__file__), '../')
#     return os.path.abspath(
#         os.path.join(safe_relative_path, sub_dir))


import unittest
import os
import qgis  # pylint: disable=unused-import
from safe.definitions.constants import INASAFE_TEST
from safe.utilities.i18n import tr, locale
from safe.common.utilities import safe_dir
from qgis.PyQt.QtCore import QCoreApplication, QTranslator
from safe.test.utilities import get_qgis_app
        from safe.definitions.constants import no_field
        from safe.definitions.constants import no_field
    """Test translations work."""

    def setUp(self):
        """Runs before each test."""
        if 'LANG' in iter(list(os.environ.keys())):
            os.environ.__delitem__('LANG')

    def tearDown(self):
        """Runs after each test."""
        if 'LANG' in iter(list(os.environ.keys())):
            os.environ.__delitem__('LANG')

    def test_impact_summary_words(self):
        """Test specific words from impact summary info shown in doc see #348.
        """
        os.environ['LANG'] = 'id'
        phrase_list = []
        message = 'Specific words checked for translation:\n'
        for phrase in phrase_list:
            if phrase == tr(phrase):
                message += 'FAIL: %s' % phrase
            else:
                message += 'PASS: %s' % phrase
        self.assertNotIn('FAIL', message, message)

        # Set back to en
        os.environ['LANG'] = 'en'

    def test_qgis_translations(self):
        """Test for qgis translations."""

# Path: safe/common/utilities.py
# def safe_dir(sub_dir=None):
#     """Absolute path from safe package directory.
# 
#     :param sub_dir: Sub directory relative to safe package directory.
#     :type sub_dir: str
# 
#     :return: The Absolute path.
#     :rtype: str
#     """
#     safe_relative_path = os.path.join(
#         os.path.dirname(__file__), '../')
#     return os.path.abspath(
#         os.path.join(safe_relative_path, sub_dir))


# Path: safe/test/test_translations.py
import unittest
import os
import qgis  # pylint: disable=unused-import
from safe.definitions.constants import INASAFE_TEST
from safe.utilities.i18n import tr, locale
from safe.common.utilities import safe_dir
from qgis.PyQt.QtCore import QCoreApplication, QTranslator
from safe.test.utilities import get_qgis_app
        from safe.definitions.constants import no_field
        from safe.definitions.constants import no_field

    """Test translations work."""

    def setUp(self):
        """Runs before each test."""
        if 'LANG' in iter(list(os.environ.keys())):
            os.environ.__delitem__('LANG')

    def tearDown(self):
        """Runs after each test."""
        if 'LANG' in iter(list(os.environ.keys())):
            os.environ.__delitem__('LANG')

    def test_impact_summary_words(self):
        """Test specific words from impact summary info shown in doc see #348.
        """
        os.environ['LANG'] = 'id'
        phrase_list = []
        message = 'Specific words checked for translation:\n'
        for phrase in phrase_list:
            if phrase == tr(phrase):
                message += 'FAIL: %s' % phrase
            else:
                message += 'PASS: %s' % phrase
        self.assertNotIn('FAIL', message, message)

        # Set back to en
        os.environ['LANG'] = 'en'

    def test_qgis_translations(self):
        """Test for qgis translations."""

        file_path = safe_dir('i18n/inasafe_id.qm')