Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manipulate data from one lang to an other one #39

Open
davidfaber opened this issue Feb 9, 2019 · 4 comments
Open

Manipulate data from one lang to an other one #39

davidfaber opened this issue Feb 9, 2019 · 4 comments

Comments

@davidfaber
Copy link

davidfaber commented Feb 9, 2019

Hi there,
Thank you so much for this awesome plugin. One thing though.... I recently added it to an existing site of mine and I came up with an SQL-Script that does two things:

  1. It moves all stored data from "All languages" to en_GB
  2. It copies existing fields to a new language (de_DE) in my case

I think this can be very useful for other users too, e.g. if add the plugin to an existing site or you add a new language and don't want to start from 0 with your settings.

Also it cleans up the "All languages"-data, which could be a good solution for Issue #37

If you tell me where and how you would like that information in your Readme, I am very happy to make the changes and open an Pull request for it.

The MySQL:

# Rename current options
UPDATE {YOUR_TABLE_PREFIX}options SET option_name = CONCAT('options_en_GB', TRIM(LEADING 'options' FROM option_name)) WHERE option_name LIKE 'options%';
UPDATE {YOUR_TABLE_PREFIX}options SET option_name = CONCAT('_options_en_GB', TRIM(LEADING '_options' FROM option_name)) WHERE option_name LIKE '_options%';

# Duplicate options
CREATE TEMPORARY TABLE tmptable_1 SELECT * FROM {YOUR_TABLE_PREFIX}options WHERE option_name LIKE 'options%' OR option_name LIKE '_options%';
UPDATE tmptable_1 SET option_id = NULL;
UPDATE tmptable_1 SET option_name = CONCAT('options_de_DE', TRIM(Leading 'options_en_GB' FROM option_name)) WHERE option_name LIKE 'options%';
UPDATE tmptable_1 SET option_name = CONCAT('_options_de_DE', TRIM(Leading '_options_en_GB' FROM option_name)) WHERE option_name LIKE '_options%';
INSERT INTO {YOUR_TABLE_PREFIX}options SELECT * FROM tmptable_1;
DROP TEMPORARY TABLE IF EXISTS tmptable_1;

# Show the results
SELECT * FROM {YOUR_TABLE_PREFIX}options WHERE option_name LIKE 'options%' OR option_name LIKE '_options%';

Thanks,
David

@MaximeCulea
Copy link
Contributor

Thank you David,

You summed up everything perfectly.

I have to take a look.

@MaximeCulea
Copy link
Contributor

It seems nice.

I will make a wp cli command to :

  • copie "all languages" values to an other
  • copie specific language values to an other

@davidfaber
Copy link
Author

That sounds like a lovely idea!

@MaximeCulea MaximeCulea changed the title Enhancement for Readme regarding data Manipulate data from one lang to an other one Apr 11, 2019
@MaximeCulea MaximeCulea mentioned this issue May 7, 2019
@MaximeCulea MaximeCulea removed their assignment Sep 18, 2019
@1ucay
Copy link

1ucay commented Oct 5, 2020

Hi, can you add as link to right metabox?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants