Source: helpers/labels.js

import Utils from './utils';
import Settings from './settings';

/**
 * Init labels by merging various settings
 */
const init = () => {
	var overrideLabels = {
		refine: initLabel('label', 'refine', 'Refine By'),
		refineMobile: initLabel('label', 'refine_mobile', 'Refine By'),
		refineMobileCollapse: initLabel('label', 'refine_mobile_collapse', 'Hide Filter'),
		clear: initLabel('label', 'clear', 'Clear'),
		clearAll: initLabel('label', 'clear_all', 'Clear All'),
		apply: initLabel('label', 'apply', 'Apply'),
		applyAll: initLabel('label', 'apply_all', 'Apply All'),
		close: initLabel('label', 'close', 'Close'),
		loadMore: initLabel('label', 'load_more', 'Load more {{ amountProduct }} Products'),
		loadMoreTotal: initLabel('label', 'load_more_total', '{{ from }} - {{ to }} of {{ total }} Products'),
		loadPreviousPage: initLabel('label', 'load_previous_page', 'Load Previous Page'),
		searchOptions: 'Search options',
		collectionAll: 'All',
		viewMore: 'View More',
		viewLess: 'View Less',
		under: 'Under',
		above: 'Above',
		ratingStar: 'Star',
		ratingStars: 'Stars',
		ratingUp: '& Up',
		showResult: 'Show Results',
		showLimit: 'Show',
		sortingList: {
			'best-selling': initLabel('label', 'sorting_best_selling', 'Best Selling'),
			'manual': initLabel('label', 'sorting_featured', 'Featured'),
			'price-ascending': initLabel('label', 'sorting_price_ascending', 'Lowest Price'),
			'price-descending': initLabel('label', 'sorting_price_descending', 'Highest Price'),
			'title-ascending': initLabel('label', 'sorting_title_ascending', 'Alphabetically, A-Z'),
			'title-descending': initLabel('label', 'sorting_title_descending', 'Alphabetically, Z-A'),
			'created-descending': initLabel('label', 'sorting_date_descending', 'Date, New to Old'),
			'created-ascending': initLabel('label', 'sorting_date_ascending', 'Date, Old to New'),
			'published-descending': initLabel('label', 'sorting_date_descending', 'Date, New to Old'),
			'published-ascending': initLabel('label', 'sorting_date_ascending', 'Date, Old to New'),
			'sale-descending': initLabel('label', 'sorting_sale_descending', '% Off'),
			'relevance': initLabel('label', 'sorting_relevance', 'Relevance')
		},
		search: {
			seoTitleOne: initLabel('label', 'search_seo_title_one', 'Search result: {{ count }} result for "{{ terms }}"'),
			seoTitleOther: initLabel('label', 'search_seo_title_other', 'Search results: {{ count }} results for "{{ terms }}"'),
			generalTitle: initLabel('label', 'search_general_title', 'Search'),
			resultHeader: initLabel('label', 'search_result_header', 'Search Results for "{{ terms }}"'),
			resultEmpty: initLabel('label', 'search_result_empty', 'Sorry, nothing found for "{{ terms }}". Check out these items instead?'),
			resultNumber: initLabel('label', 'search_result_number', 'Showing {{ count }} results for "{{ terms }}"'),
			searchPanelProduct: initLabel('label', 'search_panel_product', 'Products ({% raw %}{{ count }}{% endraw %})'),
			searchPanelCollection: initLabel('label', 'search_panel_collection', 'Collections ({% raw %}{{ count }}{% endraw %})'),
			searchPanelPage: initLabel('label', 'search_panel_page', 'Pages ({% raw %}{{ count }}{% endraw %})'),
			searchTotalResult: initLabel('label', 'search_total_result_one', 'Showing {{ count }} result'),
			searchTotalResults: initLabel('label', 'search_total_result_other', 'Showing {{ count }} results'),
		},
		suggestion: {
			placeholder: initLabel('label_suggestion', 'suggestion_placeholder', 'Search'),
			popularHeader: initLabel('label_suggestion', 'suggestion_popular_header', 'Popular Suggestions'),
			productHeader: initLabel('label_suggestion', 'suggestion_product_header', 'Products'),
			didYouMeanHeader: initLabel('label_suggestion', 'suggestion_did_you_mean_header', 'Did you mean'),
			viewAll: initLabel('label_suggestion', 'suggestion_view_all', 'View all {{ count }} product(s)'),
			suggestQuery: initLabel('label_suggestion', 'suggestion_suggest_query', 'Showing results for {{ terms }}.'),
			didYouMean: initLabel('label_suggestion', 'suggestion_did_you_mean', 'Did you mean: {{ terms }}?'),
			searchBoxPlaceholder: initLabel('label_suggestion', 'suggestion_placeholder', 'Search'),
		},
		error: {
			noFilterResult: initLabel('label_error', 'error_no_filter_result', 'Sorry, no products matched your selection'),
			noSearchResult: initLabel('label_error', 'error_no_search_result', 'Sorry, no products matched the keyword'),
			noProducts: initLabel('label_error', 'error_no_products', 'No products found in this collection'),
			noSuggestionProducts: 'Sorry, nothing found for "{{ terms }}"',
			noSuggestionResult: 'Sorry, nothing found for "{{ terms }}"'
		}
	};
	
	var mergedLabels = Utils.mergeObject(Labels, overrideLabels);

	if (typeof Settings.label !== 'undefined') {
		mergedLabels = Utils.mergeObject(mergedLabels, Settings.label);
	}
	
	Labels = mergedLabels;
};

const initLabel = (group, id, defaultValue) => {
	if (boostPFSConfig.hasOwnProperty(group) && boostPFSConfig[group].hasOwnProperty(id)) {
		return boostPFSConfig[group][id];
	}
	return defaultValue;
};

/**
 * List of all text labels in the app
 */
var Labels = {
	productFilter: 'Product filter',
	refine: 'Refine By',
	refineMobile: 'Refine By',
	refineMobileCollapse: 'Hide Filter',
	clear: 'Clear',
	clearAll: 'Clear All',
	apply: 'Apply',
	applyAll: 'Apply All',
	close: 'Close',
	back: 'Back',
	loadMore: 'Load more {{ amountProduct }} Products',
	loadMoreTotal: '{{ from }} - {{ to }} of {{ total }} Products',
	loadPreviousPage: 'Load Previous Page',
	searchOptions: 'Search options',
	collectionAll: 'All',
	viewMore: 'View More',
	viewLess: 'View Less',
	under: 'Under',
	above: 'Above',
	ratingStar: 'Star',
	ratingStars: 'Stars',
	ratingUp: '& Up',
	showResult: 'Show Results',
	showLimit: 'Show',
	sortingList: {
		'best-selling': 'Best Selling',
		'manual': 'Featured',
		'price-ascending': 'Lowest Price',
		'price-descending': 'Highest Price',
		'title-ascending': 'Alphabetically, A-Z',
		'title-descending': 'Alphabetically, Z-A',
		'created-descending': 'Date, New to Old',
		'created-ascending': 'Date, Old to New',
		'published-descending': 'Date, New to Old',
		'published-ascending': 'Date, Old to New',
		'sale-descending': '% Off',
		'relevance': 'Relevance'
	},
	search: {
		generalTitle: 'Search',
		resultHeader: 'Search Results for "{{ terms }}"',
		resultEmpty: 'Sorry, nothing found for "{{ terms }}". Check out these items instead?',
		resultNumber: 'Showing {{ count }} results for "{{ terms }}"',
		searchPanelProduct: 'Products',
		searchPanelCollection: 'Collections',
		searchPanelPage: 'Pages',
		searchTotalResult: 'Showing {{ count }} result',
		searchTotalResults: 'Showing {{ count }} results'
	},
	suggestion: {
		placeholder: 'Search',
		popularHeader: 'Popular Suggestions',
		productHeader: 'Products',
		didYouMeanHeader: 'Did you mean',
		viewAll: 'View all {{ count }} product(s)',
		suggestQuery: 'Showing results for {{ terms }}.',
		didYouMean: 'Did you mean: {{ terms }}?',
		searchBoxPlaceholder: 'Search'
	},
	error: {
		noFilterResult: 'Sorry, no products matched your selection',
		noSearchResult: 'Sorry, no products matched the keyword',
		noProducts: 'No products found in this collection',
		noSuggestionProducts: 'Sorry, nothing found for "{{ terms }}"',
		noSuggestionResult: 'Sorry, nothing found for "{{ terms }}"'
	},
	action_list: {
    	// Quickview
    	qvBtnLabel: 'Quick View',
    	qvAddToCartBtnLabel: 'Add To Cart',
    	qvSoldOutLabel: 'Sold Out',
    	qvSaleLabel: 'Sale',
    	qvQtyLeftLabel: 'Hurry, there are only {{item}} item(s) left!',
    	qvNotifyMeSuccessfullyLabel: 'Thanks! We will notify you when this product becomes available!',
    	qvNotifyMeErrorLabel: 'Please provide a valid email address.',
    	qvNotifyMeMessageLabel: 'Notify me when {{item}} becomes available',
    	qvNotifyMeFormBodyLabel: 'Please notify me when {{item}} becomes available.',
    	// Add to cart
    	atcAvailableLabel: 'Add To Cart',
    	atcSelectOptionsLabel: 'Select Options',
    	atcSoldOutLabel: 'Sold Out',
    	atcAddingToCartBtnLabel: 'Adding...',
		atcAddedToCartBtnLabel: 'Added!',
    	atcPopupAddedToCartLabel: 'has been added to shopping cart',
    	atcPopupSubtotalLabel: 'Cart Subtotal',
    	atcPopupCheckoutLabel: 'Checkout',
    	atcPopupGoToCartLabel: 'Your Cart',
    	atcPopupTotalItemsLabel: 'item(s)',
    	atcPopupCrossSellHeadingLabel: 'Frequently bought with',
    	atcMiniCartCountItemLabel: 'item(s) in your shopping cart',
    	atcMiniCartTotalItemsLabel: 'Total Items',
    	atcMiniCartSubtotalLabel: 'Subtotal',
    	atcMiniCartCheckoutLabel: 'Process Checkout',
    	atcMiniCartViewCartLabel: 'View and edit cart',
    	atcMiniCartEmptyCartLabel: 'Your Cart Is Currently Empty',
    	atcMiniCartRemoveItemLabel: 'Remove This Item',
    	atcMiniCartShopingCartLabel: 'Shopping Cart'
    },
	mostPopular: {
		popularProductsHeading: "Popular products"
	},
	recentlyViewed: {
		recentProductHeading: "Recently viewed products"
	},
	ada: {
		toggleMultiLevel: "Expand/Collapse {{filterItem}}",
		filterOption: "Filter by {{filterOption}}",
		clearFilterOption: "Clear filter by {{filterOption}}",
		clearFilterItem: "Clear filter by {{filterOption}} {{filterItem}}",
		clearAllFilterItems: "Clear all filters",
		filterOptionTitle: "Filter by {{filterOption}}",
		minValue: "Min value",
		maxValue: "Max value"
	},
	init: init,
};

export default Labels;