How to set up a bilingual store

Excursionist
699 0 7
*Initial setup* You need to open 2 separate stores, which will have separate databases. This means uploading all the product-related information twice. There's excellent information on doing that with curl "here":http://forums.shopify.com/categories/1/posts/4111. *Basic idea* What we're trying to do here is create seamless linkages between one language version and the other, so that users can use a link on each page of each site to get to the relevant page of the other site. This involves some coding, but that's relatively easy with the code given below. You can copy & paste and tweak it to your needs. The only difficulty arises with the product pages, where some sort of hook has to be devised to link from one language version of a product to the other. We're assuming the product titles and the collection titles are different in the different language versions, so they're not available for direct linking. *Disclaimer* I've hijacked the _variant_ variable for this purpose, and tested it on my store, where I only have one variant per product (the default). So the proviso is: I don't know whether this would work for a store that uses multiple variants of a product. Secondly, this is also a fairly labour-intensive method, since it involves entering a new variant name for each product for each store. So if you have 50 products, that makes 100 entries. I don't know whether any curly shortcuts exist for this. *Step 1 - Admin setup* OK, let's start: * *1 - Create your two stores* If you already have one, create a second. You will have two different accounts, and therefore your stores will have different names.Lets call them *my_french_store* and *my_english_store*. This means your variable _shop.name_ will no longer be useful, if you want to keep your brand consistent across the two stores - let's say *my_total_store* - , so you'll have to hard code that into each of the theme templates. But it's a variable that hardly ever comes up, basically just in the _title_, so that's not a problem. * *2 - Set up the index and collection linkages between the two stores* Go into admin -> navigation and set up one new link list for each store , as follows: For *my_english_store*, call this linklist *french_site*, and for *my_french_store*, call it *english_site*. For each link, choose _->links to web address_, and then enter the following, without adding or removing any of the slashes given below. I'm assuming you have your own domain address, e.g. my_total_store.com. For the following identical collections, (with the English name on the left and the corresponding French on the right), you set up this *french_site* list (in *my_english_store*): * index -> http://my_french_store.my_total_store.com * hats -> /chapeaux * gloves -> /robes * dresses ->/socks * socks -> /chaussettes And do it the other way around on *my_french_store* * *3 - Create the product linkages between the two stores* This is the gruesome part. For each product in one store, enter as a variant, the *HANDLE* of the same product in the other store. This is in admin ->products->variations->title. If you have only one variant, that text input will say "Default". Replace that. To make this clear: On *my_english_store* Velvet Moiré Gloves -> has variant title -> gants-de-velours-moir-eacute On *my_french_store* Gants de velours moiré -> has variant title -> velvet-moir-eacute-gloves _Note:_ This step would not be necessary if there were a variant "sku.url", since the SKU is the natural link between the two, being identical by definition - but to my knowledge, there isn't, so we have to create a manual link. (or lobby...:)) So, now the setup is complete for the coding. *Step 2 -Template coding* I'll just show the steps required for *my_english_store* here. They'll be reversed for *my_french_store*. At the top of templates *theme* , *product* and *collection*: (I put it before the doctype declaration):
{% for link in linklists.french_site.links %}
	{% if link.title =="index" %}
		{% assign: french_home = link.url %}
	{% endif %}
{% endfor %}
Directly following this, in the *product* template:
{% for variant in product.variants %}
	{% if variant.available == true %}
		{% assign: french_product_handle ={{variant.title}}%}
	{% endif %}
{% endfor %}
Then, somewhere in the *theme* template, wherever you want your link to appear... *THE LANGUAGE SWITCH*

{% case template %} {% when 'collection' %} {% for link in linklists.french_site.links %} {% if collection.title == link.title %} français {% endif %} {% endfor %} {% when 'product' %} {% if french_product_handle %} français {% else %} français {% endif %} {% else %} français {% endcase%}
Notice that the last link is HARD-CODED to *my_french_store*. You have to change this to your real French store url. This is because we don't have access to all the templates, so the assigned variables will fail, and in that case, everything will default to the home page of the French store. It's an anti-404 measure. So what all of this does is create a page-specific link for each product and for each collection. All the rest gets sent to the home page. I didn't include the page or blog templates, because I don't really use them, but I suppose you could do something similar if needed, for the "About" page, for example. Ya, and obviously, English and French are just an example. You could just as well set up a Chinese/Cornish store, what with all the crowdsourcing that's been going on. So: Amusez-vous bien! & with a bit of luck you'll be able to see it in action in the fairly near future (i hope!)
operation absurdist feature requests: terminated (http://en.wikipedia.org/wiki/Absurdism)
0 Likes
Tourist
108 0 1

Wow, that’s impressive. I think i understand, even though it being 11:53pm. :) Great stuff, thanks!

I’ll try to find out if this works for multiple variants of a product, since I have those in my store. I don’t see why it wouldn’t, but for thiking that through… well it’s too late in the evening. :)

Folkology - Authentic folk craft and culture from Hungary http://www.folkology.com
0 Likes
Shopify Expert
3933 15 323

Interesting! Too bad they have not yet just embraced i18n in La Capitale Nationale at Le Shopify. Could save everyone the grief of 2x the stores and inventory management!! This year maybe??

Being in Montreal I need to provide both languages.. so I make two stores.. shove half the inventory in each one, and provide a splash page to choose language.. and a language switcher link on the header of each site. Two subdomains.. will let me exchange cookies between them eh…


french.mysite.com   ==> Cookie 'language' = 'english'
english.mysite.com   ==> Cookie 'language' = 'francais'

It is a little screwed up though.. since things in a cart in one language will not show in the other language cart. So I want to keep things separate. I imagine 99.5% of all shoppers will trip in only one language anyway… but still.. I bet someone will say “tabarwhet, chek ben mon cart de colis, c’est ou mon willy waller 2006?”...

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
Shopify Staff
Shopify Staff
2002 0 41

Sticky’d

Tobias Lütke - Shopify CEO // http://twitter.com/tobi
0 Likes
Excursionist
699 0 7

welllll…I thought this was a pretty cool little system when I devised it yesterday. Cool in that It Works.

But looking at it again today, I think it’s insane – to the extent to which deliberately adding tedium to one’s life is an act of insanity; and putting in all those extra variant names can only be called tedium of the highest order…

So, naturally, my ideas run to a..

FEATURE REQUEST!!

Here’s the thinking: All of the information required is already available, so it’s pointless (and tedious) and bluntly anti-Occam to duplicate what is already there – in the form of the SKU.

So, the feature I beg to request, ye kind shopify geeks, is the following:

A variable which might be called sku.url_transform for example, or whatever you like, and which would be used to get the title of any given product and transform it into a friendly url.

So that, for the above example, if I were to code this into my_english_store :


{% case template %}
(...)
{% when 'product' %}
<a href="{{french_home}}/products/{{sku.url_transform}}
(...)
{% endcase %}

then the reference to the product (the SKU) would be stored in this new variable, which would then be sent over to my_french_store to create the standard “product.url”; that is to say, the SKU would be translated into the french title, the appropriate url created and – end of story, we go off snowboarding, while OTHER poor people working with less developed e-commerce software spend their daylight hours (tediously) typing in redundant bits of data.

It doesn’t seem to me to be too difficult to do – a matter of saying a = b and b = c, basically.

So – what do you think?

operation absurdist feature requests: terminated (http://en.wikipedia.org/wiki/Absurdism)
0 Likes
Excursionist
699 0 7

Hmm…there seems to be something wrong in my thinking this evening but I can’t quite pinpoint it. Well, actually I can.

It obviously couldn’t be a direct link, since that would go to a 404.

Help, I’m stuck – there must be some solution available along these lines, no?

Edited a few minutes later : Another thought just occurred to me: might it not be possible to give people the choice of the form of url in the “general preferences” page – i.e. if they prefer, they could opt in to a

http://www.mystore.com/products/1478
type of url, which would work with the SKU rather than using the standard urls with the product titles. (just looking at the url of this post for instance – something like that). Personally, I don’t care much if the title doesn’t appear in the url, but I’ll do (almost) anything to avoid boredom…:)

operation absurdist feature requests: terminated (http://en.wikipedia.org/wiki/Absurdism)
0 Likes
Excursionist
699 0 7

in the meantime…here’s an update to the language switch to reflect the new url structure just introduced by Tobi, which allows for navigating forward and backward within collections.

even if you don’t have your shop urls set up that way this code will still work with the previous urls. so you don’t have to change anything unless you want to use the new url scheme. in which case, copy and paste:


<div id="language">
    {% case template %}
        {% when 'collection' %}
            {% for link in linklists.french_site.links %}
                {% if collection.title == link.title %}
                    <a href="{{french_home}}/collections{{link.url}}" title="en fran&ccedil;ais"><span>fran&ccedil;ais</span></a>
                {% endif %}
            {% endfor %}
        {% when 'product' %}
            {% if french_product_handle != "Default" %}
                {% if collection %}
                    <a href="{{french_home}}/collections/{{collection.handle}}/products/{{french_product_handle}}" title="en fran&ccedil;ais"><span>fran&ccedil;ais</span></a>
                {% else %}
                    <a href="{{french_home}}/collections/{{french_product_handle}}" title="en fran&ccedil;ais"><span>fran&ccedil;ais</span></a>
                {% endif %}
            {% else %}
            <a href="{{french_home}}" title="en fran&ccedil;ais"><span>fran&ccedil;ais</span></a>
            {% endif %}
        {% else %}
            <a href="http://my_french_store.my_total_store.com" title="en fran&ccedil;ais"><span>fran&ccedil;ais</span></a>
    {% endcase%}
</div>

operation absurdist feature requests: terminated (http://en.wikipedia.org/wiki/Absurdism)
0 Likes
Shopify Staff
Shopify Staff
2002 0 41

We mean (for the last 6 months) to make the handles of products, link-lists, collections and so on editable. If we would allow this you could use the same handles between your french and english shop and use this for the switch.

Tobias Lütke - Shopify CEO // http://twitter.com/tobi
0 Likes
Excursionist
699 0 7

WOOOOWWW!!

I can’t even BEGIN to tell you how thrilled I would be!!

All I’m trying to do is have a bilingual store with a bilingual blog for information articles &c, which would also refer to the products – so, I’m finding myself running 3 different applications (2 shopify stores plus a CMS), uploading every single product picture and description 3 times, into 3 different data bases, dealing with two sets of human languages and 2 sets of tag languages – liquid and expression engine tags, 4 different urls for each product and no clear connections between anything, so I have to cobble everything together laboriously, as described above; and this is taking (wasting) a LOT of my time.

which I would LOVE to have for some other stuff – like marketing for example…where I’m totally and desperately talentless; and the point, – besides having fun – is also to start making a little money at some point…

So if there’s any way you can move that up on your priority list, I’ll break out the champagne!

operation absurdist feature requests: terminated (http://en.wikipedia.org/wiki/Absurdism)
0 Likes
Excursionist
1027 0 8

That would be awesome. When I first set up our store the title’s I used on some of the products are not what I wanted to use down the road. The fact that the search engines had already indexed these urls, I couldn’t go through and change the product title because that would also effect the url.

In the meantime I hacked it using liquid to change the title, but this is more code than necessary and its just makes maintaining and updating our liquid files that much harder. If we were able to seperatly change the url and the title where they weren’t the same thing, that would allow everyone to change the title of the product while maintaining the current url. Very helpful.

This feature I am really looking forward to…

@Christina, make sure you pour me a glass!!

Dan - http://www.xtremechargers.com
0 Likes