Skip to content

Commit

Permalink
code 't' filter without rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
edadma committed May 4, 2018
1 parent 4053089 commit e362db9
Show file tree
Hide file tree
Showing 7 changed files with 362 additions and 8 deletions.
9 changes: 9 additions & 0 deletions htdocs/404.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="page-width">
<div class="empty-page-content text-center">
<h1>{{ 'general.404.title' | t }}</h1>
<p>{{ 'general.404.subtext' | t }}</p>
<p>
<a href="/" class="btn btn--has-icon-after">{{ 'general.404.link' | t }}</a>
</p>
</div>
</div>
327 changes: 327 additions & 0 deletions htdocs/locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,327 @@
{
"general": {
"accessibility": {
"skip_to_content": "Skip to content",
"close_modal": "Close (esc)"
},
"meta": {
"tags": "Tagged \"{{ tags }}\"",
"page": "Page {{ page }}"
},
"404": {
"title": "404 Page Not Found",
"subtext": "The page you requested does not exist.",
"link": "Continue shopping"
},
"pagination": {
"previous": "Previous",
"next": "Next",
"current_page": "Page {{ current }} of {{ total }}"
},
"password_page": {
"opening_soon": "Opening Soon",
"login_form_heading": "Enter store using password",
"login_form_password_label": "Password",
"login_form_password_placeholder": "Your password",
"login_form_submit": "Enter",
"signup_form_email_label": "Email",
"signup_form_success": "We will send you an email right before we open!",
"admin_link_html": "Are you the store owner? <a href=\"\/admin\" class=\"text-link\">Log in here<\/a>",
"password_link": "Enter using password",
"powered_by_shopify_html": "This shop will be powered by {{ shopify }}"
},
"social": {
"share_on_facebook": "Share",
"share_on_twitter": "Tweet",
"share_on_pinterest": "Pin it",
"alt_text": {
"share_on_facebook": "Share on Facebook",
"share_on_twitter": "Tweet on Twitter",
"share_on_pinterest": "Pin on Pinterest"
}
},
"search": {
"no_results_html": "Your search for \"{{ terms }}\" did not yield any results.",
"results_with_count": {
"one": "{{ count }} result for \"{{ terms }}\"",
"other": "{{ count }} results for \"{{ terms }}\""
},
"title": "Search our site",
"placeholder": "Search",
"submit": "Submit",
"close": "Close search"
},
"newsletter_form": {
"newsletter_email": "Join our mailing list",
"email_placeholder": "Email address",
"confirmation": "Thanks for subscribing",
"submit": "Subscribe"
},
"filters": {
"show_more": "Show More",
"show_less": "Show Less"
}
},
"sections": {
"slideshow": {
"next_slide": "Next slide",
"previous_slide": "Previous slide",
"pause_slideshow": "Pause slideshow",
"play_slideshow": "Play slideshow",
"play_video": "Play video",
"close_video": "Close video"
},
"map": {
"address_error": "Error looking up that address",
"address_no_results": "No results for that address",
"address_query_limit_html": "You have exceeded the Google API usage limit. Consider upgrading to a <a href=\"https:\/\/developers.google.com\/maps\/premium\/usage-limits\">Premium Plan<\/a>.",
"auth_error_html": "There was a problem authenticating your Google Maps account."
}
},
"blogs": {
"article": {
"view_all": "View all",
"all_topics": "All topics",
"by_author": "by {{ author }}",
"posted_in": "Posted in",
"read_more": "Read more",
"back_to_blog": "Back to {{ title }}"
},
"comments": {
"title": "Leave a comment",
"name": "Name",
"email": "Email",
"message": "Message",
"post": "Post comment",
"moderated": "Please note, comments must be approved before they are published",
"success_moderated": "Your comment was posted successfully. We will publish it in a little while, as our blog is moderated.",
"success": "Your comment was posted successfully! Thank you!",
"comments_with_count": {
"one": "{{ count }} comment",
"other": "{{ count }} comments"
}
}
},
"cart": {
"general": {
"title": "Your cart",
"note": "Add a note to your order",
"remove": "Remove",
"subtotal": "Subtotal",
"savings": "You're saving",
"shipping_at_checkout": "Shipping & taxes calculated at checkout",
"update": "Update",
"checkout": "Check out",
"empty": "Your cart is currently empty.",
"cookies_required": "Enable cookies to use the shopping cart",
"edit": "Edit",
"cancel": "Cancel",
"continue_shopping": "Continue shopping"
},
"label": {
"product": "Product",
"price": "Price",
"quantity": "Quantity",
"total": "Total"
}
},
"collections": {
"general": {
"view_all": "View all",
"no_matches": "Sorry, there are no products in this collection",
"items_with_count": {
"one": "{{ count }} product",
"other": "{{ count }} products"
}
},
"sorting": {
"title": "Sort",
"featured": "Featured",
"best_selling": "Best Selling",
"az": "Alphabetically, A-Z",
"za": "Alphabetically, Z-A",
"price_ascending": "Price, low to high",
"price_descending": "Price, high to low",
"date_descending": "Date, new to old",
"date_ascending": "Date, old to new"
},
"filters": {
"title_tags": "Filter",
"all_tags": "All products"
}
},
"contact": {
"form": {
"name": "Name",
"email": "Email",
"phone": "Phone Number",
"message": "Message",
"submit": "Send",
"post_success": "Thanks for contacting us. We'll get back to you as soon as possible."
}
},
"customer": {
"account": {
"title": "My Account",
"details": "Account Details",
"view_addresses": "View Addresses",
"return": "Return to Account Details"
},
"activate_account": {
"title": "Activate Account",
"subtext": "Create your password to activate your account.",
"password": "Password",
"password_confirm": "Confirm Password",
"submit": "Activate Account",
"cancel": "Decline Invitation"
},
"addresses": {
"title": "Your Addresses",
"default": "Default",
"add_new": "Add a New Address",
"edit_address": "Edit address",
"first_name": "First Name",
"last_name": "Last Name",
"company": "Company",
"address1": "Address1",
"address2": "Address2",
"city": "City",
"country": "Country",
"province": "Province",
"zip": "Postal\/Zip Code",
"phone": "Phone",
"set_default": "Set as default address",
"add": "Add Address",
"update": "Update Address",
"cancel": "Cancel",
"edit": "Edit",
"delete": "Delete",
"delete_confirm": "Are you sure you wish to delete this address?"
},
"login": {
"title": "Login",
"email": "Email",
"password": "Password",
"forgot_password": "Forgot your password?",
"sign_in": "Sign In",
"guest_title": "Continue as a guest",
"guest_continue": "Continue"
},
"orders": {
"title": "Order History",
"order_number": "Order",
"date": "Date",
"payment_status": "Payment Status",
"fulfillment_status": "Fulfillment Status",
"total": "Total",
"none": "You haven't placed any orders yet."
},
"order": {
"title": "Order {{ name }}",
"date": "Placed on {{ date }}",
"cancelled": "Order Cancelled on {{ date }}",
"cancelled_reason": "Reason: {{ reason }}",
"billing_address": "Billing Address",
"payment_status": "Payment Status",
"shipping_address": "Shipping Address",
"fulfillment_status": "Fulfillment Status",
"discount": "Discount",
"shipping": "Shipping",
"tax": "Tax",
"product": "Product",
"sku": "SKU",
"price": "Price",
"quantity": "Quantity",
"total": "Total",
"fulfilled_at": "Fulfilled {{ date }}",
"subtotal": "Subtotal",
"track_shipment": "Track shipment"
},
"recover_password": {
"title": "Reset your password",
"email": "Email",
"submit": "Submit",
"cancel": "Cancel",
"subtext": "We will send you an email to reset your password.",
"success": "We've sent you an email with a link to update your password."
},
"reset_password": {
"title": "Reset account password",
"subtext": "Enter a new password for {{ email }}",
"password": "Password",
"password_confirm": "Confirm Password",
"submit": "Reset Password"
},
"register": {
"title": "Create Account",
"first_name": "First Name",
"last_name": "Last Name",
"email": "Email",
"password": "Password",
"submit": "Create"
}
},
"homepage": {
"onboarding": {
"product_title": "Your product's name",
"product_description": "This area is used to describe your product’s details. Tell customers about the look, feel, and style of your product. Add details on color, materials used, sizing, and where it was made.",
"collection_title": "Your collection's name",
"blog_title": "Your post's title",
"blog_excerpt": "Your store hasn’t published any blog posts yet. A blog can be used to talk about new product launches, tips, or other news you want to share with your customers. You can check out Shopify’s ecommerce blog for inspiration and advice for your own store and blog.",
"blog_author": "Author name",
"no_content": "This section doesn’t currently include any content. Add content to this section using the sidebar."
}
},
"layout": {
"navigation": {
"search": "Search",
"toggle": "expand\/collapse",
"expand": "expand",
"collapse": "collapse"
},
"cart": {
"title": "Cart",
"items_count": {
"one": "item",
"other": "items"
}
},
"customer": {
"account": "Account",
"log_out": "Log out",
"log_in": "Log in",
"create_account": "Create account"
},
"footer": {
"social_platform": "{{ name }} on {{ platform }}"
}
},
"products": {
"product": {
"regular_price": "Regular price",
"sold_out": "Sold out",
"unavailable": "Unavailable",
"on_sale": "Sale",
"quantity": "Quantity",
"add_to_cart": "Add to cart",
"back_to_collection": "Back to {{ title }}"
}
},
"gift_cards": {
"issued": {
"title_html": "Here's your {{ value }} gift card for {{ shop }}!",
"subtext": "Your gift card",
"disabled": "Disabled",
"expired": "Expired on {{ expiry }}",
"active": "Expires on {{ expiry }}",
"redeem_html": "Use this code at checkout to redeem your {{ value }} gift card",
"shop_link": "Start shopping",
"print": "Print this gift card",
"remaining_html": "{{ balance }} left",
"add_to_apple_wallet": "Add to Apple Wallet"
}
},
"date_formats": {
"month_day_year": "%B %d, %Y"
}
}
1 change: 1 addition & 0 deletions htdocs/snippets/icon-arrow-right.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<svg aria-hidden="true" focusable="false" role="presentation" class="icon icon--wide icon-arrow-right" viewBox="0 0 20 8"><path d="M15.186.445c.865.944 1.614 1.662 2.246 2.154.631.491 1.227.857 1.787 1.098v.44a9.933 9.933 0 0 0-1.875 1.196c-.606.485-1.328 1.196-2.168 2.134h-.752c.612-1.309 1.253-2.315 1.924-3.018H.77v-.986h15.577c-.495-.632-.84-1.1-1.035-1.406-.196-.306-.486-.843-.87-1.612h.743z" fill="#000" fill-rule="evenodd"/></svg>
9 changes: 9 additions & 0 deletions htdocs/templates/404.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="page-width">
<div class="empty-page-content text-center">
<h1>{{ 'general.404.title' | t }}</h1>
<p>{{ 'general.404.subtext' | t }}</p>
<p>
<a href="/" class="btn btn--has-icon-after">{{ 'general.404.link' | t }}{% include 'icon-arrow-right' %}</a>
</p>
</div>
</div>
16 changes: 11 additions & 5 deletions src/main/scala/ExtraFilters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,25 @@ object ExtraFilters {
var translations: JSON = _

def translate( settings: Map[Symbol, Any], key: String, vars: Map[String, String] ) = {
if (translations == null || locale != settings("locale")) {
locale = settings("locale").toString
translations = DefaultJSONReader.fromFile( docroot(s"locale/$locale", settings) )
if (translations == null || locale != settings('locale)) {
locale = settings('locale).toString
translations = DefaultJSONReader.fromFile( docroot(s"locales/$locale.json", settings) )
}

translations getString key
def traverse( k: List[String], obj: AnyRef ): String =
k match {
case Nil => obj.toString
case h :: t => traverse( t, obj.asInstanceOf[Map[String, AnyRef]](h) )
}

traverse( key split "\\." toList, translations )
}

override def parameters = List( List(StringType) )

override def apply( settings: Map[Symbol, Any], args: List[Any], named: Map[String, Any] ) =
args match {
case List( s: String ) =>
case List( key: String ) => translate( settings, key, named.asInstanceOf[Map[String, String]] )
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object Main extends Testing with App {
val res =
test(
"""
|{{ 1.2 | floor: 'asdf', first: 'wow' }}
|{{ 'general.404.title' | t }}
""".trim.stripMargin, false
)

Expand Down
Loading

0 comments on commit e362db9

Please sign in to comment.