(function(){

    'use strict';

    angular.module('PortalSearch').config(function ($translateProvider) {
    //Telling the translateService where to get the locale files from
        $translateProvider.translations('en', {
	"direction_style": "direction:ltr",
	"advanced_search_label": "Advanced Search",
	"search_results_label": "Search Results",
	"search_options_label": "Search Options",
	"find_all_these_words_label": "Find all these words",
	"none_of_these_words_label": "None of these words",
	"the_exact_phrase_label": "The <u>exact</u> phrase",
	"date_of_publishing_from_to_label": "Date of publishing (From-To)  ",
	"results_in_format_label": "Results in format",
	"all_format_label": "All Format",
	"format_label": "Format",
	"all_label": "All",
	"results_language_label": "Results Language",
	"lang_label": "Lang",
	"related_entity_label": "Related Entity",
	"life_event_label": "Life Events",
	"entity_label": "Entity",
	"search_in_label": "Search in",
	"portal_label": "Portal",
	"external_label": "External",
	"only_show_results_from_label": "Only show result from",
	"all_portal_content_and_category_label": "All Portal content and categories",
	"selected_categories_label": "Selected Categories",
	"services_label": "Services",
	"live_events_label": "Live Events",
	"government_entities_label": "Governament Entities",
	"open_data_platform_label": "Open Data Platform",
	"news_label": "News",
	"blogs_label": "Blogs",
	"locations_label": "Locations",
	"communities_label": "Communities",
	"popular_search_label": "Popular Search",
	"search_subject_label": "Search subject",
	"did_you_mean_label": "Did you mean",
	"defaultRowCount": "10",
	"no_results_label": "No Results found related to the entered search word",
	
	"original_url_label": "Original URL",
	"publishing_date_label": "Publishing Date",
	"search_result_type_label": "Search Result Type",

	"en_label": "En",
	"ar_label": "Ar",
	"Other_label": "Other",

        "couldnt_find_label": "DIDN’T FIND WHAT YOU WERE LOOKING FOR?",
	
	"filtering_by_label": "Filtering by",
	"locale_facet_label": "Language",
	"category_en_facet_label": "Category",
	"category_ar_facet_label": "Category",
    "sector_en_facet_label": "Sector",
	"sector_ar_facet_label": "Sector",
	"content_format_facet_label": "Content Format",
	"source_facet_label": "Source",
	"publish_date_facet_label": "Publish Date",
	"related_entity_en_facet_label": "Related Entity",
	"related_entity_ar_facet_label": "Related Entity",
	"life_event_en_facet_label": "Life Events",
	"life_event_ar_facet_label": "Life Events",
	
	"ANY_TIME_facet_label": "Any time",
	"LAST_MONTH_facet_label": "Last month",
	"LAST_YEAR_facet_label": "Last year",
	"CUSTOM_facet_label": "Custom",
	"from_label": "from",
	"to_label": "to",
	
	"show_more_label": "Show more",
	"show_less_label": "Show less",

	"sort_by_label": "Sort by",
	"relevancy_label": "Relevancy",
	"category_label": "Category",
    "sector_label": "Sector",
	"file_type_label": "File Type",
	"source_label": "Source",
	"publish_date_label": "Publish Date",
	"help_label": "Help",
	"cancel_label": "Cancel",
	"search_label": "Search ",
	"add_label": "Add",
	"back_label": "Back",
	"back_to_search_label": "Back to search",
	"edit_label": "Edit",
	"delete_label": "Delete",

	"placeholder_search_box_label": "Search for services, sectors, government entities, Open data… etc",
	"placeholder_predictive_auto_correct_label": "Predictive, auto complete, spell check and correction",

	"info_no_results_found_label": "No Results found related to the entered search word",
	
	"error_fetching_suggestion_label": "No suggestions found"
}
);
  
        $translateProvider.translations('ar', {
	"direction_style": "direction:rtl",
	"advanced_search_label": "البحث المتقدم",
	"search_results_label": "نتائج البحث",
	"search_options_label": "خيارات البحث",
	"find_all_these_words_label": "كل هذه الكلمات",
	"none_of_these_words_label": "ليس من هذه الكلمات",
	"the_exact_phrase_label": "كلمات مطابقة",
	"date_of_publishing_from_to_label": "تاريخ النشر",
	"results_in_format_label": "نوع النتائج",
	"all_format_label": "جميع الأشكال",
	"format_label": "الشكل",
	"all_label": "الكل",
	"results_language_label": "لغة النتائج",
	"lang_label": "لغة",
	"related_entity_label": "المؤسسة ذات الصلة",
	"life_event_label": "أحداث الحياة",
	"entity_label": "جهة",
	"search_in_label": "ابحث في",
	"portal_label": "داخلي",
	"external_label": "خارجي",
	"only_show_results_from_label": "اظهار النتائج من",
	"all_portal_content_and_category_label": "جميع فئات محتوى الموقع",
	"selected_categories_label": "الفئات المختارة",
	"services_label": "الخدمات",
	"live_events_label": "احداث الحياة",
	"government_entities_label": "الجهات الحكومية",
	"open_data_platform_label": "البيانات المفتوحة",
	"news_label": "الأخبار",
	"blogs_label": "المدونات",
	"locations_label": "الموقع",
	"communities_label": "المجتمعات",
	"popular_search_label": "البحث الشائع",
	"search_subject_label": "موضوع البحث",
	"did_you_mean_label": "هل تعني",
	"defaultRowCount": "10",
	"no_results_label": "لا يوجد نتائج متعلقة بكلمة البحث المدخلة",
	
	"original_url_label": "الرابط الأصلي",
	"publishing_date_label": "تاريخ النشر",
	"search_result_type_label": "نوع النتيجة",

	"en_label": "En",
	"ar_label": "Ar",
	"Other_label": "Other",

        "couldnt_find_label": "لم تجد ما تبحث عنه؟",
	
	"filtering_by_label": "تصفية حسب",
	"locale_facet_label": "اللغة",
	"category_en_facet_label": "الفئة",
	"category_ar_facet_label": "الفئة",
    "sector_en_facet_label": "القطاع",
	"sector_ar_facet_label": "القطاع",
	"content_format_facet_label": "نوع النتائج",
	"source_facet_label": "المصدر",
	"publish_date_facet_label": "تاريخ النشر",
	"related_entity_en_facet_label": "جهات ذات صلة",
	"related_entity_ar_facet_label": "جهات ذات صلة",
	"life_event_en_facet_label": "أحداث الحياة",
	"life_event_ar_facet_label": "أحداث الحياة",
	
	"ANY_TIME_facet_label": "أي وقت",
	"LAST_MONTH_facet_label": "الشهر السابق",
	"LAST_YEAR_facet_label": "السنة السابقة",
	"CUSTOM_facet_label": "من-إلى",
	"from_label": "من",
	"to_label": "إلى",
	
	"show_more_label": "عرض المزيد",
	"show_less_label": "عرض اقل",

	"sort_by_label": "ترتيب حسب",
	"relevancy_label": "الصلة",
	"category_label": "فئة",
    "sector_label": "قطاع",
	"file_type_label": "نوع الملف",
	"source_label": "مصدر",
	"publish_date_label": "تاريخ النشر",
	"help_label": "مساعدة",
	"cancel_label": "إلغاء الأمر",
	"search_label": "بحث ",
	"add_label": "أضف",
	"back_label": "عودة",
	"back_to_search_label": "عودة إلى البحث",
	"edit_label": "تعديل",
	"delete_label": "حذف",

	"placeholder_search_box_label": "ابحث عن الخدمات، القطاعات، الهيئات الحكومية، البيانات المفتوحة ... الخ",
	"placeholder_predictive_auto_correct_label": "التنبؤية، الإكمال التلقائي، والتدقيق الإملائي والتصحيح",

	"info_no_results_found_label": "لا يوجد نتائج متعلقة بكلمة البحث المدخلة",
	
	"error_fetching_suggestion_label": "لا يوجد اقتراحات"
}
);
    //Providing a list of supported languages and mappings
    $translateProvider.registerAvailableLanguageKeys(
        ['ar', 'en'],
        {
            'en*': 'en',
            'ar*': 'ar',
            '*': 'en'
        }
    );
    //Fallback locale in case browser locale is not supported
    $translateProvider.fallbackLanguage('en');
      
    $translateProvider.useSanitizeValueStrategy('escape');
    //Get the browser locale
    //$translateProvider.determinePreferredLanguage();
  });

  var myspHelper = ns_Z7_59DIGCK0M8T000ADVFDROI1OF6_spHelper;
  
  //      i18n controller
  angular.module('PortalSearch').controller('Ctrl', Ctrl);

  Ctrl.$inject = ["$rootScope", "$scope", "$translate"];

  function Ctrl ($rootScope, $scope, $translate) {
    this.changeLanguage = function (key) {
      $translate.use(key);
    };

    this.changeLanguage(myspHelper.renderingLocale.substring(0, 2));
  };

})();
